- Home /
Ball in Pong dissapears after hitting paddle
teh paddle is kinetic the ball isnt its disapeares the box colider stays where it is they both have rigidbodies
heres teh ball movement code:
using UnityEngine; using System.Collections;
public class BallMovement : MonoBehaviour {
public int ballspeed;
// Use this for initialization
void Start () {
int randomDirection = Random.Range(1,2);
if (randomDirection == 1){
rigidbody.AddForce(Vector3.left * ballspeed);
}
if (randomDirection == 2){
rigidbody.AddForce(Vector3.right * ballspeed);
}
}
it just stops
I think you need to add more information.
Explain the setup, step through what happens in the scene, etc.
$$anonymous$$aybe an ASCII diagram even, this is not alot.
All I can say here is if your Range doesnt return either of thos numbers, then it will stay still so perhaps throw a Debug.log so you can see what its returning.
ie:
using UnityEngine; using System.Collections;
public class Ball$$anonymous$$ovement : $$anonymous$$onoBehaviour {
public int ballspeed;
// Use this for initialization
void Start () {
int randomDirection = Random.Range(1,2);
Debug.log("randomDirection: "+randomDirection);
if (randomDirection == 1){
rigidbody.AddForce(Vector3.left * ballspeed);
}
if (randomDirection == 2){
rigidbody.AddForce(Vector3.right * ballspeed);
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How can I make my game work for touch screens? 1 Answer
Help Touch inputs 0 Answers
Spray painting 0 Answers
Need Help making a simple game! 2 Answers