- Home /
Duplicate Question - http://answers.unity3d.com/questions/topics/cs0103.html
Red code? Why?
Hello Community!
As of now, i am really frustrated, as my script just wont work and recently started to give me several error messages... I am trying to make a "player" GameObject jump, as it impacts a platform. The jump mehtod (wich i actually transphered in this script because i wasnt sure if it would work if called from outside the original class {thats where i see the only possible problem..} ) works totally fine in the orginal calss, and gets called 100 percently in this script, it just does not work in this script...
But my actual problem is, that somehow several parts of my script are suddenly displayed red (not available?). Even the innheritance of the class "MonoBehaviour" at the class declaration. As i hover my mouse over it, it says: "error CS103: The name 'MonoBehaviour' does not exist in the current context." Please see sceenshots.
using UnityEngine;
using System.Collections;
public class GravityOnImpact : MonoBehaviour
{
public float AdditionalGravityFactor;
bool jumpTriggered;
GameObject player;
references references;
PlayerControl playerControl;
IsTouchingPlayer jumpTriggerCollider;
freezeTransform freezePos;
ConstantForce constantForce;
void Start()
{
references = gameObject.AddComponent<references>();
player = references.getPlayer ();
playerControl = references.getPlayerControl();
jumpTriggerCollider = this.GetComponentInChildren<IsTouchingPlayer>();
constantForce = this.GetComponent<ConstantForce> ();
freezePos = this.GetComponent<freezeTransform> ();
jumpTriggered = false;
}
// Update is called once per frame
void FixedUpdate () {
if (jumpTriggerCollider.playerTouch && !jumpTriggered) {
player.rigidbody.AddForce ((transform.up * 20) * 2, ForceMode.Impulse); // <--- Actual jump-method
//playerControl.jump();
jumpTriggered = true;
}
}
}