,Hi,
I am a beginner in C sharp.
I just compiled this code and I don’t know how to make the camera stop.
Please help.
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public Rigidbody rigidBody;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
if ( Input.GetKey("w"))
{
GetComponent().AddForce(0,0,500 * Time.deltaTime);
}
if ( Input.GetKey("d"))
{
GetComponent().AddForce(500 * Time.deltaTime,0,0);
}
}
}
But I would suggest setting a reference to the rigid body in start instead of using GetComponent in a loop like Update. It use ressources with each calls.