m very new to this but have a passion for it and Ive looked this up everywhere and nothing seems to be quite like my problem.
using UnityEngine;
public class PlayerMovement : MonoBehaviour { public Rigidbody rb;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
rb.AddForce(0, 0, 20, * Time.deltaTime);
}
}
This line makes no sense:
rb.AddForce(0, 0, 20, * Time.deltaTime);
please check your commas again. AddForce comes in two overloads and either takes a single Vector3 value or 3 seperate float values. Both overloads can take an additional parameter ForceMode to change how the values actually affect the rigidbody.
My guess is that you wanted to do this:
rb.AddForce(0, 0, 20 * Time.deltaTime);
Next time please do some sanity checks first. An expression like * Time.deltaTime
makes no sense. The *
operator always requires two operands.
If it’s on the same line as the //, it’s commented out.