Hello I am having a problem since changing an old command (Rigidbody.rigidbody) for a new updated one( UnityEngine.Component.Rigidbody.rigidbody;) I am getting these Invaild Token Errors The script looks OK except for this one error I can’t solve can someone please help?
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (GravityBody))]
public class FirstPersonHoverTank : MonoBehaviour {
// public vars
public float mouseSensitivityX = 250;
public float mouseSensitivityY = 250;
public float hoverSpeed = 20;
public float jumpForce = 1000f;
public float hoverForce = 65f;
public float hoverHeight = 3.5f;
public LayerMask groundedMask;
// System vars
bool grounded;
Vector3 moveAmount;
Vector3 smoothMoveVelocity;
float verticalLookRotation;
Transform cameraTransform;
UnityEngine.Component.Rigidbody.rigidbody;
void Awake() {
Screen.lockCursor = true;
cameraTransform = Camera.main.transform;
rigidbody = GetComponent<Rigidbody> ();
}
void Update() {
// Look rotation:
transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * mouseSensitivityX * Time.deltaTime);
verticalLookRotation += Input.GetAxis("Mouse Y") * mouseSensitivityY * Time.deltaTime;
verticalLookRotation = Mathf.Clamp(verticalLookRotation,-60,60);
cameraTransform.localEulerAngles = Vector3.left * verticalLookRotation;
// Calculate movement:
float inputX = Input.GetAxisRaw("Horizontal");
float inputY = Input.GetAxisRaw("Vertical");
Vector3 moveDir = new Vector3(inputX,0, inputY).normalized;
Vector3 targetMoveAmount = moveDir * walkSpeed;
moveAmount = Vector3.SmoothDamp(moveAmount,targetMoveAmount,ref smoothMoveVelocity,.15f);
// Jump
if (Input.GetButtonDown("Jump")) {
if (grounded) {
rigidbody.AddForce(transform.up * jumpForce);
}
}
// Grounded check
Ray ray = new Ray(transform.position, -transform.up);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1 + .1f, groundedMask)) {
grounded = true;
}
else {
grounded = false;
}
}
void FixedUpdate() {
// Apply movement to rigidbody
Vector3 localMove = transform.TransformDirection(moveAmount) * Time.fixedDeltaTime;
rigidbody.MovePosition(rigidbody.position + localMove);
}
}