Hi,
I have an parent object which contains the player object and a object the player looks to be pushing in front of him, together they make a rectangle shape. The parent object transform is placed in the middle of the back of the player. It’s a 3d platformer so I’m getting floats (zAxis/ xAxis) from the horizontal en vertical axis, then put those in a vector3 and add those * playerSpeed to the current position. The movement works fine, my problem is dealing with rotation. I would like the parent object to rotate on the Y axis based on the floats used for movement. It’s for a mobile game so I’m using crossplatform input.
This line “transform.Rotate (0, (zAxis - xAxis), 0)” in the script that’s on the parent object works but it keeps rotating after I’m in the desired rotation because it keeps adding on.
Is it possible to get a direction variable based of the current horizontal/vertical axis and use that to rotate the parent object and stop rotating it when it’s there and start rotating when the input changes? I’ve been trying to wrap my head around it but I’m not getting it. Any help would be very much appreciated.