- Home /
2.5d Player Controller
Hello, I am making a 2.5 d game , like with camera view on 2d and with 3d models (just explaining for some reasons ,i know you guys know about 2.5d) , Just have a problem about controlling ,i don't want to my character to go to x axis (in 2d i know it's x and y) in 2.5 d i have to lock z axis , but my player is 3d and it is looking at z so i need my player to go forward with it's look and i want to lock x axis so my player smoothly move to y(up/down) and z(forward/backward),I tried that -
using UnityEngine;
using System.Collections;
public class force : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Time.timeScale = 0.5f;
if(Input.GetKey(KeyCode.UpArrow))
{
//GetComponent<Rigidbody>().velocity = new Vector2(0, 12);
GetComponent<Rigidbody>().AddForce(Vector3.up * 200,ForceMode.Acceleration);
}
if(Input.GetKey(KeyCode.DownArrow))
{
//GetComponent<Rigidbody>().velocity = new Vector2(0,-12);
GetComponent<Rigidbody>().AddForce(Vector3.down * 200,ForceMode.Acceleration);
}
if(Input.GetKey(KeyCode.LeftArrow))
{
//GetComponent<Rigidbody>().velocity = new Vector2(-12, 0);
GetComponent<Rigidbody>().AddForce(Vector3.back * 200,ForceMode.Acceleration);
}
if(Input.GetKey(KeyCode.RightArrow))
{
//GetComponent<Rigidbody>().velocity = new Vector2(12, 0);
GetComponent<Rigidbody>().AddForce(Vector3.forward * 200,ForceMode.Acceleration);
}
}
}
but it won't work at all , even if i tried to lock z with vector 2 but it still move to z but i want to lock x , and i tired vector 3 but it still won't work , it sill moving to x . any help, thanks .
Your answer
Follow this Question
Related Questions
Pushing a ball in a direction -1 Answers
Applying custom forces without rigidbody collisions? 0 Answers
Set Velocity at relative position. 2 Answers
Why does the train jump? 1 Answer
Friction between two rigidbodies 0 Answers