check out the ghosts vs. monsters code sample on the Ansca website. I modified their code (kind of hacked it together) to do something similar:
local angleBetween = math.ceil(math.atan2( (valueY -
canonBall.y), (valueX - canonBall.x) ) \* 180 / math.pi) + 90
-- Formula: 90 + (math.atan2(y2 - y1, x2 - x1) \* 180 / PI)
-- restrict movement
local rotAmt = angleBetween + 180
if ((rotAmt-360) \>=0 and (rotAmt-360) \< 90) then
canonBall.rotation = angleBetween + 180
end
Here I’m calculating the angle between the finger (valueX, valueY) and the canonBall’s x and y. Then I add 180 as I’m doing a pull back motion to fire so I’m switching the angle so that if I pull back and move u and down it rotates correctly. I do this at fire time so it shoots correctly.
I also restrict the angle of the shot.
Another idea is to use the physics editor (in the 3rd party tools) to create a shape that is nose heavy and make sure when y you “fire” it you don’t just shoot it straight up (make sure it has angle) and set the density to a good amount (4? 5?) and I would “think” the physics engine would take over as long as it has enough time to do so while in flight. I haven’t tested this myself yet.
Another thing to do is to calculate the arc from start to collision, and then determine the rotation and change it at intervals with a timer.
These are just some thoughts, hopefully someone will have a simple solution for you if those don’t help.
-d [import]uid: 27681 topic_id: 11211 reply_id: 40662[/import]