Hello everyone I am having a little issue with this simple project
I am making a 3d breakout game in which I want to make the ball move in X and Z direction respectively. I have used the code for ball movement from Unity’s Breakout game tutorial.
After using the code, the ball is only moving horizontally (X DIRECTION) at the same spot.
How do I make it move in z direction also freely
Thanks in advance
using UnityEngine;
using System.Collections;
public class Ball : MonoBehaviour {
public float ballInitialVelocity= 600f;
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.isKinematic = false;
rb.AddForce(new Vector3(ballInitialVelocity, ballInitialVelocity,0));
}
}
}
