Aiming turret actor towards mouse position fails beyond a certain point
solsticesondesign
Member Posts: 2
I have a turret on a character that is set to aim towards the mouse.
vectorToAngle( game.Mouse.Position.X - game.Player X , game.Mouse.Position.Y - game.Player Y )
My player X and Y are constrained to the position of the core actor (the main character)
As the player moves beyond the initial camera zone, the turret seems to believe the X position remains in that zone.
I'll post screens of what I mean, I've tried everything I can think of and nothing helps.
Any ideas?
Comments
vectorToAngle( (game.Mouse.Position.X + camera Orgin X) - game.Player X , (game.Mouse.Position.Y + camera Orgin Y) - game.Player Y )
You will need to unlock the turret actor in order to acces the scene attributes (where you will find Camera Orgin X and Y).
"the turret seems to believe the X position remains in that zone"
It does ! 'mouse' position refers to the mouse/touch position of the screen not your scene, so if you move your camera 4,000 pixels to the right and 3,600 pixels upwards, then touch the middle of - for example - an iPad screen (1024 x 768) the call will return a value of 512, 384 . . . . regardless of where your camera moves to the physical screen you are interacting with stays put.
What if the turret actor spawns on the main actor upon interaction with another actor (button or item pickup). This seems to make it so the turret is only in the scene during gameplay, I can't find a way to unlock it within the inspector.
This is true. You cannot unlock a spawned actor. (Because it does not exist to unlock.)
But you can make an instance of the actor and unlock it. Then you can place it off-camera where the user will never see it until you move it into place. Basically you hide it until you need it. To the user, it will seem as if the actor was spawned -- but actually it was there all the time.