- Home /
AddForce doesn't work
heey guys I want to learn the basics so i decided i make flappybird! try unity but onfortunitly i get stuck at these problems. Can someone explain to me what the problems are? what do i wrong?
using UnityEngine;
using System.Collections;
public Vector3 flappyForce = new Vector3(0,50,0);
public class Flappyscript : MonoBehaviour {
void Start () {
}
void Update () {
if (Input.GetKeyDown("space")){
Rigidbody,AddForce(flappyForce)
}
}
}
Answer by starlight996 · Apr 11, 2014 at 08:14 PM
It should be rigidBody.AddForce, you have a capital R in rigidbody and comma instead of a full stop between rigidbody and addforce, :)
Answer by Adamcbrz · Apr 11, 2014 at 08:05 PM
I am assuming your script doesn't compile.
1) move the variable declaration inside the class.
2) Rigidbody should be rigidbody
Answer by ForeignGod · Apr 11, 2014 at 08:42 PM
As all others have said basicly replace line 14 with;
rigidbody.AddForce(flappyForce)
Answer by xEoDx · Apr 12, 2014 at 08:45 AM
Also, notice that you have a comma instead of a dot :) And yes, change Rigidbody to rigidbody
Your answer