Question by
Blahhhhhhhhhhhhhh · Feb 29, 2016 at 04:23 AM ·
c#velocityconstant
How do I get ball to go the same speed for the game Pong?
Here is My Script using UnityEngine; using System.Collections;
public class Ball : MonoBehaviour {
public float ballVelocity = 3000;
Rigidbody rb;
bool isPlay;
int randInt;
void Awake ()
{
rb = gameObject.GetComponent<Rigidbody> ();
randInt = Random.Range(1, 3);
}
void Update ()
{
if(Input.GetMouseButton(0) == true && isPlay == false)
{
transform.parent = null;
isPlay = true;
rb.isKinematic = false;
if (randInt == 1)
{
rb.AddForce(new Vector3(ballVelocity,ballVelocity,0));
}
if (randInt == 2)
{
rb.AddForce(new Vector3(-ballVelocity,-ballVelocity,0));
}
}
}
}
Comment
Answer by curly-brace · Feb 29, 2016 at 05:46 AM
remove drag value from properies
Drag is located on the rigidbody component, if you can't find it.
Answer by Blahhhhhhhhhhhhhh · Feb 29, 2016 at 03:57 PM
Here's a screenshot of my rigidbody for my ball. It still goes slow.
drag.jpg
(39.4 kB)
That should be working, if not, try increasing ballVelocity.
I already tried that. Need help.? @$$anonymous$$01098
I tried increasing the velocity. The speed I have it set to is 3000 so I increased it to 4000 then 6000 and it goes a good speed in the beginning then it goes even slower than it did before. @$$anonymous$$01098
Your answer