Hi Guys, How do I go about flipping a character on the X axis in a 2D game?
I have a shooter named “Player” that follows the mouse and i need this guy to do something like
if mouse X position is less then Player’s X position flip the Player Game Object to face left and VS
so another words as the player looks and aims at the mouse he also looks good when the mouse goes behind the player
I can’t get this to work… is there some sort of game example or tutorial that shows how to flip an object based on mouse position? I am sure this is pretty simple but i can’t figure it out
You can’t directly change the x value of localscale. You need to create a temporary vector3, assign the localscale, modify it and reassign the updated vector3 back to the localScale.
EDIT
To check the location of the mouse in world space, use ScreenToWorldPoint to convert the mouse position and compare the x of both the returned value of the mouse position and your object’s position.