I am working on a Snooker Game project in Unity3D. I have achieved the feels of snooker physics. But while taking the spin shoots it is doing some wired activity. I have added torque after adding force in certain direction. Can any one please suggest me what exactly I have missed.
Here is my code
using UnityEngine;
using System.Collections;
public class CueBall : MonoBehaviour {
private enum SPIN{ nospin, leftspin,rightspin,topspin,bottomspin};
private SPIN currentSpin = SPIN.topspin;
private float cueStrength = 1000.0f;
public Transform cueStick;
// Use this for initialization
void Start () {
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
}
// Update is called once per frame
void FixedUpdate () {
if(Input.GetMouseButtonDown(0)){
gameObject.rigidbody.drag = 0.6f;
gameObject.rigidbody.mass = 1.2f;
gameObject.rigidbody.angularDrag = 1.5f;
switch(currentSpin){
case SPIN.topspin :
rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);
rigidbody.AddTorque(Vector3.back * cueStrength );
break;
case SPIN.bottomspin:
rigidbody.AddForceAtPosition(cueStick.forward * cueStrength,transform.position,ForceMode.Acceleration);
rigidbody.AddTorque(Vector3.forward * cueStrength );
break;
}
}
}
}
Thank you advance