Constrain the angle of the canon towards the player
BigDave
Member Posts: 2,239
I guess you guys have a quick answer for this.
I want a canon that always points towards the player position. So I can place multiple canon's at different locations that all point to the player.
I constraint the X and Y of the Player as global game variables.
Within the canon actor code I did
(vectorToAngle( game.PlaneX , game.PlaneY ))
So I got the angle for the Player.
So now I have to figure how to get the coordinations of both compared so when I move my player it checks the difference between this two actor types.
How exactly would that work?
Comments
@BigDave, vectorToAngle takes the difference between Tower and player position.
So you need to do
vectorToAngle(self.Position.X-game.PlaneX,self.Position.Y-game.PlaneY)
then rotate the tower to that angle.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch Thanks man! Let's try it.
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
@Hopscotch
Hat to add the start angle behind but else it worked perfectly!
vectorToAngle(self.Position.X-game.PlaneX,self.Position.Y-game.PlaneY)-90
Thanks again. This thread is answered.
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
You can also do this with the Rotate To behaviour . . . .
@socks
haha wtf thats awesome!
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de