GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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 Posts: 797Member

    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 Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef

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

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

  • djtackldjtackl Posts: 10Member

    @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 Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef
    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 Posts: 10Member

    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 Posts: 2,824Member, Sous Chef, PRO

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

  • djtackldjtackl Posts: 10Member
    edited November 2015

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

    Yeah... Wow. Thanks.

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

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

Sign In or Register to comment.