How to constrain cannon angle to the player angle, so it rotates to shoot the player.
I am creating a boss enemy which will shoot the player, it will upto rotate to a particular angle and shoot the player in real time. So have to contsrain it's rotation to a particular angle as well as make it rotate by ai according to player x and y position.
How do I achieve this effect? Can any one help?
How do I achieve this effect? Can any one help?
Comments
vectorToAngle( self.Position.X - game.PLAYER X , self.Position.Y - game.PLAYER Y )
you'll also need to make 2 global attributes called player X and Y and constrain those to your player's self position X and Y
that will keep it from going beyond, but you'll must likely need to make 2 more rules to bring it back,
if self rotation is equal or greater then self max(320), change self rotation to 319
if self rotation is equal or less then self min(220), change self rotation to 221
I THINK that would work...but I haven't tested it so maybe not
I would think you can just tell the cannon to spawn the lightning at rotation relative to self and it would work tho, then you don't need to have extra code within the lightning actor, if I am understanding you correctly that is
another actor is making the fire true or false for every 5 secs and after 5.6 seconds..
walk with arrow keys, use jet pack with space bar
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Download it quickly!
https://www.dropbox.com/sh/9gqiviyqfbjs7xz/Me9jyf_C3_
Eduard0369 thanks, but my that problem got solved.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS