Question by
AussieAUQLD · Jun 12, 2017 at 03:28 AM ·
c#unity 5positionplayercontroller
Remember position for a simple player controller (Left/Right)?
Goal is for the player to move left.x axis and move right on the same spot where left.x stopped. Right now when i push to go right axis but it teleports not from the stopping point from left but it goes straight to 0 and starts from their.
How would i make it remember the old position from left so it's like (Example, moves left -1, -2, -3 and now wants to move right -3, -2, -1, 0, 1, 2, 3)
if (Input.GetKeyDown (KeyCode.LeftArrow))
{
//left (Same as right but with sRight+=amountToMoveEachTimeRight and Rightarrow)
transform.position = new Vector3 (sLeft+=amountToMoveEachTimeLeft, this.transform.position.y, this.transform.position.z);
}
ca.jpg
(26.0 kB)
Comment