So what i want to do is this: an cube that moves using the the WASD keys (done), a triangle that moves the same time with the cube(like a turet on a tank) and a sphere that moves on 2 axes(like X and Y doesnt matter very much) but using the mouse(like a cursor) and the triangle must point to the sphere(i have a script but any other script would be helpfull). So i want a want to make the triangle move the same time with the cube, but if you can give me some kind of script for all i want to do would be wonderfull.
Thanks in advance! A basic sketch would be something like this.
yes , the only thing a bit difficult is get the point 3d of the mouse.
but if under the tank is a plane, is easy
can using a plane under the tank (name this plane as “plane” (not plane.001) with a brick sensor -mouse over-
python->
#####
import bge
cn=bge.logic.getCurrentController()
owner=cn.owner
mouse=cn.sensors["Mouse"]
if mouse.positive:
pos=mouse.hitPosition
owner["pointMouse"]=pos
#####
[“pointMouse”] is the point 3D which the tower of tank must follow
now, from the turret of tank(always sensor TRUE PULSE) :
######
import bge
cn=bge.logic.getCurrentController()
owner=cn.owner
sce=bge.logic.getCurrentScene()
pointMouse=sce.objects["plane"]["pointMouse"]
vec=owner.getVectTo(pointMouse)
owner.alignAxisToVect(vec[1],1,0.1)
######
should work!
The attached file implements my interpretation of your requirements:
Attachments
TurretTargetTrack.blend (485 KB)
“invalid attachment specified” error… reload the file?
The file should be downloadable now…