Aiming turret actor towards mouse position fails beyond a certain point

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?

http://imgur.com/a/x6uv8

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    vectorToAngle( (game.Mouse.Position.X + camera Orgin X) - game.Player X , (game.Mouse.Position.Y + camera Orgin Y) - game.Player Y )

  • SocksSocks London, UK.Member Posts: 12,822

    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.

  • solsticesondesignsolsticesondesign Member Posts: 2

    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.

    @Socks said:
    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.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @solsticesondesign said:
    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.

Sign In or Register to comment.