- Home /
Question by
unity_-CPWhSIR2jD2uQ · May 11, 2020 at 08:17 AM ·
jumping object
i want to make a ball jump 1 time please can i have someones script?
so far i have this public float thrust; public Rigidbody rb;
void Start() { rb = GetComponent(); }
void FixedUpdate() { Vector3 tilt = new Vector3(Input.acceleration.x, 0, -Input.acceleration.z); if (Input.GetMouseButtonDown(0)) { //jump here rb.AddForce((Vector3.up + tilt) * thrust, ForceMode.Impulse); //or any force mode you prefer } }
but it given me this error how do i fix it? Assets\script\player controller.cs(1,14): error CS0116: A namespace cannot directly contain members such as fields or methods
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612233540im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
jumping at a degrees angle 1 Answer
how to make a realistic jump? Very urgent please :( 0 Answers
having a subtle issue with my juump script 1 Answer
bumper script 1 Answer
Rigidbody jump 0 Answers