1
\$\begingroup\$

I am trying to create a path for a gameObject which will bounce off other gameObjects if it hits them. Can I get an idea on how I could possibly get this curve path set up.

Stuck on ideas. I don't want to use ITween and I can't simply define the entire path via ITween either. I need to account for whether it hit another gameObject and cause it to carry on the path or just fall through.

Attached the image below for clarification. I need the circle(purple) gameObject to bounce along the white path provided the rectangle(green) gameObject is in place to cause a Trigger and let the path carry on or the circle gameObject just simply falls through.

There is only 1 green gameObject at any point of time which moves to one of the 3 possible positions. Placed 2 just for clarification.

enter image description here

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

If the only deviation from the path is falling through you could make the object follow a parabolic function, check it at a certain point and if your green thing is there then send the object back along the same parabola. You can use something like this graph calculator to find the right curve.

y = -(a*x)*(x - contact)

If you modify 'a' in the equation above you can modify the height of the parabola while still hitting the x axis at 'contact'. a = 2 will be taller while a = 0.5 will be shorter.

\$\endgroup\$
2
  • \$\begingroup\$ will u be able to show me a simple example. \$\endgroup\$ Mar 19, 2015 at 18:18
  • \$\begingroup\$ bounce_dist = 100; //distance between each bounce x_pos += x_speed * elapsed_time; //Update position x_parab_pos = (x_pos % bounce_dist); parab_direction = -1; // turns the parabola upsidedown y_pos += parab_direction * (height_modifier * x_parab_pos) * (x_parab_pos - bounce_dist) + y_fallthough_pos; if (y_pos < y_fallthough_pos + 1 && !checkForThinger() ){ ... } That's probably more simple than what you'd want to implement (as speed fixed to x axis might not be the effect you want) but it would be along these lines. \$\endgroup\$
    – NovaCrist
    Mar 20, 2015 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .