How do i move an object under an angle in js?
This is currently the script i have:
static var speed : int = 5;
var movement : Vector3 = Vector3(1f, 1f, 0f).normalized;
function Update () {
if (Input.GetKey(KeyCode.UpArrow)){
transform.Translate(Vector3.up * Time.deltaTime*speed);
transform.Translate(Vector3.right * Time.deltaTime*speed);
}
else if (Input.GetKey(KeyCode.DownArrow)){
transform.Translate(Vector3.down * Time.deltaTime*speed);
transform.Translate(Vector3.left * Time.deltaTime*speed);
}
else if (Input.GetKey(KeyCode.LeftArrow)){
transform.Translate(Vector3.up * Time.deltaTime*speed);
transform.Translate(Vector3.left * Time.deltaTime*speed);
}
else if (Input.GetKey(KeyCode.RightArrow)){
transform.Translate(Vector3.down * Time.deltaTime*speed);
transform.Translate(Vector3.right * Time.deltaTime*speed);
}
}
Which works fine, but it moves the character at strictly 45 degree angles, but my camera and map setup have a bit smaller angles, and the character ends up slowly sliding out of the drawn bounds. How do i adjust the script so i can move at manually set angles?
Comment
Your answer
Follow this Question
Related Questions
My Isometric TileMap is going up 0 Answers
Designing 2D Level suggestion 0 Answers
Help with jumping in isometric perspective (2d)? 0 Answers
Isometric Tilemaps Error 0 Answers
For Dimetric Game, use Unity 2D or 3D? 0 Answers