Shoot to mouse (vectorToAngle) issue
h.rashid13
Member Posts: 4
In my project, I have it set so that a projectile is spawned on mouse click and it's velocity is changed to:
vectorToAngle(mouse.posX - actor.posX, mouse.posY - actor.posY)
so that my projectiles are always fired to the mouse location.
The issue is when I move to a particular part of the scene. Suddenly, the mouse-to-actor angles start to mess up. They work fine when the actor is near the beginning of the scene, but the angles become wild as I move through the scene.
I have attached my project so that you can take a look. Frank is the main actor, Projectile is the bullet, each are constrained to Game variables. WASD to move and mouse to shoot.
http://www.mediafire.com/download.php?e4jiasougjvalkd (Mac)
http://www.mediafire.com/download.php?jctxycwpjqmn8g0 (PC)
vectorToAngle(mouse.posX - actor.posX, mouse.posY - actor.posY)
so that my projectiles are always fired to the mouse location.
The issue is when I move to a particular part of the scene. Suddenly, the mouse-to-actor angles start to mess up. They work fine when the actor is near the beginning of the scene, but the angles become wild as I move through the scene.
I have attached my project so that you can take a look. Frank is the main actor, Projectile is the bullet, each are constrained to Game variables. WASD to move and mouse to shoot.
http://www.mediafire.com/download.php?e4jiasougjvalkd (Mac)
http://www.mediafire.com/download.php?jctxycwpjqmn8g0 (PC)
Best Answer
-
RThurman Posts: 2,880@h.rashid13 -- The projectile actor is not taking the camera movement into account. This forum discussion might help:
http://forums.gamesalad.com/discussion/11744/shoot-to-xy-problems
Answers
Take a look:
http://forums.gamesalad.com/discussion/54617/video-why-can-i-rotate-an-actor-only-until-270-or-270#latest
make sure the value you are using to calculate your angles is an Absolute (abs) value.
Hi @h.rashid13 if you're updating an attribute with the results of your vectorToAngle, make sure this attribute is set to Angle and it'll work fine for you.
Here's a little test to show you what I mean:
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps