- Home /
unity game breakout tutorial ball problem
Hello i am a newbie in unity ! I am making "BreakOut" game ! in which we have to break all the bricks with a ball . my problem is that my ball slows down after first or second hit and i want it to maintain a constant velocity of 600f.. any help please
Comment
here is the code:
using UnityEngine; using System.Collections;
public class Ball : $$anonymous$$onoBehaviour { public float ballInitialVelocity= T600f;
private Rigidbody rb;
private bool ballInPlay;
// Use this for initialization
void Awake () {
rb= GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1") && ballInPlay ==false)
{
transform.parent =null;
ballInPlay =true;
rb.is$$anonymous$$inematic=false;
rb.AddForce(new Vector3 (ballInitialVelocity,ballInitialVelocity ,0));
}
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to change the speed of the gameobject moving on the itween path 1 Answer
Creating floor using transforms 0 Answers
Progress lost after resetting game 2 Answers