I wanted to make a "kogelbaan" (wiki links it to the english "Trajectory of a projectile")
I used
and
for the parabola. but when I try to chance the angle from 45 to 44 or 46 is doesn't do as expected.
What did I do wrong?
in my code I used dutch words(hoek = angle, tijd = time, kracht = force, kogel = bullet)
public GameObject kogel;
private float tijd;
private float hoek = 45f;
private float kracht = 1f;
public int aantalkogels = 1;
// Use this for initialization
void Start () {
for (int i = 0; i < aantalkogels; i++)
{
GameObject kloonkogel = (GameObject)Instantiate(kogel);
kloonkogel.name = "Kogel"+(i+1);
}
}
// Update is called once per frame
void Update () {
tijd = Time.timeSinceLevelLoad;
for (int i = 0; i < aantalkogels; i++)
{
GameObject active = GameObject.Find("Kogel"+(i+1));
if (active != null)
{
active.transform.position = new Vector3(kracht * (Mathf.Cos(hoek)* Mathf.Rad2Deg) * tijd, (kracht * (Mathf.Sin(hoek)*Mathf.Rad2Deg) * tijd - (5)*(tijd * tijd)) + (15 * i));
if(active.transform.position.y < 0)
{
//DestroyObject(active);
}
}
}
}
angle = hoek. I want that people can give a angle and a force and that they need to try to get the bullet to hit the target.
– anon47167959