I am new to unity and C# and I am trying to limit the velocity of a rigidbody. I am using this script but it says ‘,’ expected and I put in a “,” and it says "only assignment, call, increment, decrement and new object expressions can be used as a statement for the whole line.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
public class NewBehaviourScript : MonoBehaviour
{
public float maxSpeed = 1000f;
void Update()
{
if (GetComponent<Rigidbody>().velocity.magnitude > maxSpeed)
{
(GetComponent<Rigidbody>().velocity = Vector3.ClampMagnitude((GetComponent<Rigidbody>().velocity), maxSpeed)); } //This line
}
}