Hello, In my game I have these stationary turrets that I want rotate to face the player actor at all times. I'm having trouble figuring this out. Thanks
Keep a track of the player's X and Y coordinates by constraining player self.positionx to a variable called 'playerX' and player self.positiony to a variable called 'playerY'.
Then, on your turrets, put in the behaviour rotate to
and in the X and Y fields, hit the little 'e' button next to it and make the X field 'playerX' and the Y field 'playerY'.
So far I have two GAME attributes which are playerX and playerY. they are set to 0 and both are integers In my player's actor I have two "Constrain Attributes" self.Postion.X To PlayerX and self.Position.Y To PlayerY
As far as what goes into the turrets I am confused how to set everything up.
a constraint constantly checks and changes whatever is being constrained. So if you are constraining the rotation of something to something else using VectorToAngle it is constantly checking the angle and then changing the rotation to that angle. Therefore constraints are also cpu intensive but should be a lot smoother looking than a timer system and probably less cpu intensive than a timer. Use both timers and constrains sparingly.
Comments
Then, on your turrets, put in the behaviour rotate to
and in the X and Y fields, hit the little 'e' button next to it and make the X field 'playerX' and the Y field 'playerY'.
Hope that makes sense,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Thanks for you help
So far I have two GAME attributes which are playerX and playerY. they are set to 0 and both are integers
In my player's actor I have two "Constrain Attributes" self.Postion.X To PlayerX and self.Position.Y To PlayerY
As far as what goes into the turrets I am confused how to set everything up.
game.playerX to: self.position.x
game.playerY to: self.position.y
Offset angle: 0
Do the switch as FMG said.
Your method is cpu intensive and won't work for large projects with lots of turrets. Timers eat cpu.
Trust us, you don't need a timer. You need to use constraints.