- Home /
The question is answered, right answer was accepted
error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
using UnityEngine;
using System.Collections;
public class playercontroller : MonoBehaviour
{
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("input.Horizontal");
float moveVertical = Input.GetAxis ("input.Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody>(Vector3);
}
}
it also displays: "error CS0308: The non-generic method `UnityEngine.Component.GetComponent(System.Type)' cannot be used with the type arguments" i was copying the code for the "roll a ball" project and this is after i fixed it after it said i didnt have my vertical axis setup and now it won t let me play until i fix it.
$$anonymous$$oderators
Answers/answering comments from mod queue should be set to "Visible by Everyone" to avoid disappearing answers when converted.
Answer by Landern · Mar 25, 2015 at 12:37 PM
on line 13, you're passing a TYPE, the type is Vector3, it expected the type to be constructed and qualified.
GetComponent<Rigidbody>(Vector3);
should have a value of some sort.
GetComponent<Rigidbody>().AddForce(new Vector3(1.1f, 2.5f, 0));
Vector3 also supplies simple Vector3 objects(forward, back, etc.) which you can see as static variables that return Vector3 objects, this is described at the beginning of the Vector3 documentation.
I'll try fixing that thank you it stopped throwing errors but now the problem is the ball won't move, maybe this will fix that thank you again.
@Landern i'm very sorry as i'm just trying to learn to code but what do the values represent? (1.1f, 2.5f, 0) are these supposed to be the coordinate of the object i'm trying to put input into? i tried putting exactly what you put as a example and it now has one error stating:"No overload for method 'GetComponent' takes '1' arguments"
Are you trying to get the rigidbody to move? Try this:
GetComponent<Rigidbody>().AddForce(movement);
See here: http://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
holy crap that worked but now "Unhandled Exception: System.UnauthorizedAccessException: Access to the path "C:\Users\conoman316\Documents\games\New folder\roll a ball\Temp\Assembly-CSharp.dll.mdb" is denied." its denying access to the folder??
Thats a Windows issue. Open Unity in Ad$$anonymous$$ mode. This QA is answered.