Mouse Position Off
djtackl
Member Posts: 10
I need my player to go to the mouse position. I set the player to point towards to mouse position using vectorToAngle. I set it to move in direction of the mouse at speed ((Distance to mouse*5)2). The player does its movement speed corectly, but the player is always off of the mouse to the left and down.
Does anyone know how to fix this?
Comments
Your actor is moving into the bottom left corner? If so you have your move rules not moving towards the mouse or it is going the wrong direction in the move rule.
Can you post the actual expression you're using for vectorToAngle?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
vectorToAngle(self.position.x-game.Mouse.position.x, self.position.y-game.Mouse.position.y)-180
You might have to play around with the offset value (-180). I made a quick demo on Mac -- attached -- but since you're using a PC, try this with an actor that has an image pointing up (90°):
Constrain Attribute self.Rotation to vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )+90
Move [Direction: vectorToAngle( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )-180] [Speed: whatever you like] [Relative to: Scene]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
HERE is a link to the test build I am on. Try it, and tell me if the position offset happens to you. I've tried messing with the numbers to change values, but nothing works.
Did you by any chance change the camera's origin?
Yeah... Wow. Thanks.
Add whatever you have changed the camera's x and y coordinates into your equations.