Hello!
I’m using the Firt Person Controller that comes with unity, and y want to implement a jetpack, but it was not possible for me to have a reference of the CharacterMotor reference in order to call methods from it to change the velocity…
i think my problem is that my script is in C#, and CharacterMotor is written in Javascript… but I have no idea how this could be a problem…
this is my script, very simple:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(CharacterMotor))]
public class JetPack : MonoBehaviour
{
CharacterMotor motor;
void Awake()
{
motor = GetComponent<CharacterMotor>();
}
// Update is called once per frame
void Update()
{
//this do not work :(
//object grounded = motor.IsGrounded();
//if(grounded)
// Debug.Log("AAA");
if(Input.GetButtonDown("Fire2"))
motor.SetVelocity(Vector3.up);
}
//this works
void OnJump()
{
Debug.Log("OnJump");
}
//this works
void OnLand()
{
Debug.Log("OnLand");
}
}
but when i try to compile, it shows this error:
JetPack.cs(31,31): Error CS0584: Internal compiler error: $SubtractNewPlatformVelocity$3 (CS0584) (Assembly-CSharp)
JetPack.cs(31,31): Error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement (CS0201) (Assembly-CSharp)
on this line
motor.SetVelocity(Vector3.up);
what can i do?