- Joined
- May 8, 2022
- Messages
- 3
- Reaction score
- 0
I started learning unity coding in c# today. I am following a tutorial from a youtuber's playlist. I have copied all the code but when I start on unity I have a problem. I have code that makes a cube have force. However, the cube does not launch. here is the code:
using UnityEngine;
public class PlayerMovment : MonoBehaviour {
public Rigidbody rb;
public float fowardForce = 2000f;
// Update is called once per frame
void fixedUpdate()
// use Time.deltaTime to sync frames with force
{
rb.AddForce(0, 0, fowardForce * Time.deltaTime);
if ( Input.GetKey("d") );
{
rb.AddForce(500 * Time.deltaTime, 0, 0);
}
}
}
Any idea what the problem is? Thank you.
using UnityEngine;
public class PlayerMovment : MonoBehaviour {
public Rigidbody rb;
public float fowardForce = 2000f;
// Update is called once per frame
void fixedUpdate()
// use Time.deltaTime to sync frames with force
{
rb.AddForce(0, 0, fowardForce * Time.deltaTime);
if ( Input.GetKey("d") );
{
rb.AddForce(500 * Time.deltaTime, 0, 0);
}
}
}
Any idea what the problem is? Thank you.