Hi Guys, just thought I would post this here, it is a modified DragLaunch Script that allows you the developer to switch on and off a test mode, that will allow you to bowl the perfect game meaning now more stopping and starting
- Simply select the ball and click the developer test mode and enter in the perfect shot velocity mine was 0,0,1500
- When you want a challenge simply deselect the developer test mode
Code is Below
private Ball ball;
private Vector3 dragStart, dragEnd;
private float startTime, endTime;
//Test Code (To Be Removed)
public bool developerTest;
public Vector3 developerTestVelocity;
// Use this for initialization
void Start () {
ball = GetComponent<Ball>();
}
public void DragStart(){
//Capture time and posistion of drag start
dragStart = Input.mousePosition;
startTime = Time.time;
}
public void DragEnd(){
//Launch the ball
dragEnd = Input.mousePosition;
endTime = Time.time;
float dragDuration = endTime - startTime;
float launchSpeedX = (dragEnd.x - dragStart.x) / dragDuration;
float launchSpeedZ = (dragEnd.y - dragStart.y) / dragDuration;
//Note developerTest & developerTestVelocity to be removed just in place to auto roll the ball correctly
if (developerTest == false){
Vector3 launchVelocity = new Vector3(launchSpeedX, 0, launchSpeedZ);
if(ball.inPlay == false){
ball.Launch(launchVelocity);
}
}else {
ball.Launch(developerTestVelocity);
}
}
public void MoveStart (float amount){
//Debug.Log ("Ball Moved " + amount);
if(ball.inPlay == false){
ball.transform.Translate(new Vector3 (amount,0,0));
}
}