- Home /
why is it every single time i higher the number for the speed the speed of the ball stays the same? PLEASE HELP ITS SO FRUSTRATING!!!!!!!!!!!
using System.Collections; using System.Collections.Generic;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void start ()
{
rb = GetComponent<Rigidbody>();
}
void fixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
that is my code (anything wrong? plz help), using System.Collections; using System.Collections.Generic;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void start ()
{
rb = GetComponent<Rigidbody>();
}
void fixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
that is my code, anything wrong?
Have you actually changed the value of speed in the inspector, or just the script?
Answer by smark12007 · Jul 24, 2020 at 06:34 PM
The first letter of the method to catch message from unity should be upper.
start -> Start
fixedUpdate -> FixedUpdate
Also, sometimes you could put Debug.Log in your script to see whether the program runs the function properly.
Answer by mbro514 · Jul 24, 2020 at 06:09 PM
Does the rigidbody for your ball have any drag? If so, the drag might be preventing your ball from going beyond a certain speed, regardless of how much force you add to it.
Your answer
Follow this Question
Related Questions
"Mouse Scrollwheel" on xbox 360controller 2 Answers
Limit number of face buttons being simultaneously held. 1 Answer
Question about moving an object technique 3 Answers
How to change the walk speed of the FPSController from another script? 2 Answers
MMD How to export model and animations to Unity as 3rd person controller? 2 Answers