- Home /
Question by
foureyes44 · Mar 01, 2018 at 01:55 AM ·
c#variablefloatcompiler errorcompiler-error
Monodevelop files a compiler error when I try to make a variable,Monodevelop files complilerr error when I try to make a public variable
Here's my Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public float DeForce01 = 420f;
public class FloatBob : MonoBehaviour {
public Rigidbody rb;
// Update is called once per frame
void Update () {
rb.AddForce (0,0, DeForce01 * Time.deltaTime );
}
}
,Here's my code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public float DeForce01 = 420f;
public class FloatBob : MonoBehaviour {
public Rigidbody rb;
// Update is called once per frame
void Update () {
rb.AddForce (0,0, DeForce01 * Time.deltaTime );
}
}
`
Comment
Your variable needs to be in the class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FloatBob : $$anonymous$$onoBehaviour {
public float DeForce01 = 420f;
public Rigidbody rb;
// Update is called once per frame
void Update () {
rb.AddForce (0,0, DeForce01 * Time.deltaTime );
}
}
Best Answer
Answer by foureyes44 · Mar 30, 2018 at 02:07 AM
Someone Commented that I had to put my variable in the class. [face palm]
Your answer
Follow this Question
Related Questions
Variables from one script to another. 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I make my own Remote Settings backend like Unity Analytics Remote Settings? 0 Answers
summing up items price in runtime 1 Answer