- Home /
Adding curve to a frisbee in virtual reality
Hi there, I am currently building a daydream vr game for frisbee throwing. I have the frisbee throwing mechanics working quite well, but even when using the controller to throw the frisbee at an angle, the frisbee did not curve around as in real life, it just flies straight. I'd like to add this curve effect and have already seen an answer on this in unity answers but it does not take into account this is a vr app using the daydream controller. Here is my code, specifically relevant is the ThrowFrisbee() function. Thanks, Duncan
public class ControllerManagerScript : MonoBehaviour {
public GameObject ballSpawn;
public GameObject Frisbee;
private Vector3 ballAccel;
private Vector3 ballLastVelocity;
// Use this for initialization
void Start () {
ballSpawn.SetActive(false);
ballAccel = new Vector3 (1f, 1f, 1f);
}
// Update is called once per frame
void Update () {
if (GvrController.ClickButtonDown) {
// show ball as visible to start throw
ballSpawn.SetActive(true);
}
ballAccel = (ballSpawn.transform.position - ballLastVelocity) / Time.fixedDeltaTime;
ballLastVelocity = ballSpawn.transform.position;
if (GvrController.ClickButtonUp) {
ThrowFrisbee ();
ballSpawn.SetActive(false);
}
}
void ThrowFrisbee () {
GameObject ballObj = (GameObject) Instantiate (Frisbee);
ballObj.transform.position = ballSpawn.transform.position;
ballObj.transform.rotation = ballSpawn.transform.rotation;
Rigidbody rb = ballObj.GetComponent ();
rb.AddForce (ballAccel.x * 2.0f, ballAccel.y * 2.0f, ballAccel.z * 2.0f, ForceMode.Impulse);
}
}
Answer by duncangroberts · Jan 23, 2017 at 12:43 PM
Someone has suggested adding a proportional force over time depending on the angle the frisbee is at. I know how to add force to the rigid body but proportional in relation the the angle of the frisbee is difficult!
Your answer
![](https://koobas.hobune.stream/wayback/20220612105316im_/https://answers.unity.com/themes/thub/images/avi.jpg)