I try to move a 3d character like a 2d character in a platform game.
What I mean is; when I press D, the character rotate and move to the right ,
and when I press A, the character rotate and move to the left .
I was thinking to reference the local axis of the character to the world axis && press A,D than rotate 180 degrees, else - stay your current direction .
I dont know if its the way to do it, and I dont know how to code it.
Im new to c#/
Thank you
just wrote a quick demo for you. Basically it takes two keyboard input:
-
when user press A and B it uses
transform.Rotate
method, while passes a vector as it’s rotation direction and speed.using UnityEngine;
using System.Collections;public class rotate : MonoBehaviour {
// Update is called once per frame void Update () { if (Input.GetKey(KeyCode.A)) { rotateMove(-1); } else if (Input.GetKey(KeyCode.D)) { rotateMove(1); } } private void rotateMove(int dir) { gameObject.transform.Rotate(0, dir, 0); }
}
Thanks a lot, realy appreciate your answer,
I come from the world of 3d, not scripting,
if you need anything - help with modeling ,texturing…whatever I can help, just ask.