Mouse Position Off

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

  • SLOCM3ZSLOCM3Z Member Posts: 797

    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,937

    Can you post the actual expression you're using for vectorToAngle?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • djtackldjtackl Member Posts: 10

    @tatiang said:
    Can you post the actual expression you're using for vectorToAngle?

    vectorToAngle(self.position.x-game.Mouse.position.x, self.position.y-game.Mouse.position.y)-180

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,937
    edited November 2015

    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

  • djtackldjtackl Member Posts: 10

    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.

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

    Did you by any chance change the camera's origin?

  • djtackldjtackl Member Posts: 10
    edited November 2015

    @RThurman said:
    Did you by any chance change the camera's origin?

    Yeah... Wow. Thanks.

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

    Add whatever you have changed the camera's x and y coordinates into your equations.

Sign In or Register to comment.