-2
\$\begingroup\$

What i'm trying to do

Hi guys , I want the ball to stick to the path and whenever it find a corner like in the image it continue normally without flying away .

\$\endgroup\$
  • 1
    \$\begingroup\$ What have you tried so far? Why did it fail? Are you using curves to draw a path? Do you want the ball to follow the line strictly, or using physics? (as in, the line is the ground) \$\endgroup\$ – TomTsagk Jul 24 '18 at 14:46
  • \$\begingroup\$ I didn't try nothing, I just want to solve this problem I don't care if I use physics or something else just help me to solve this problem , thanks :) \$\endgroup\$ – Si Lawas Jul 24 '18 at 14:49
  • \$\begingroup\$ The reason I'm asking is that I can't understand what your desired result is, so I can't give you a solution. A ball following a line is completely different than a ball that is bouncing on a line, different scenarios, different solutions. I'm just trying to save the time of someone giving you a solution you are not interested in. \$\endgroup\$ – TomTsagk Jul 24 '18 at 14:55
  • \$\begingroup\$ are know man , it's not rocket science . I just want when the player touch the screen the ball move but along the path like it should collide ;) \$\endgroup\$ – Si Lawas Jul 24 '18 at 14:59
1
\$\begingroup\$

Did you try using a path? I mean using a line renderer to create a visual path and later on you take the positions of this path and simply let you ball follow it.

LineRenderer line = Get...;
ball.LookAt(line.GetPosition(currentIndex));//just an example

You also could try to give the ball a huge mass and no drag and move the ball with rigid.velocity = x; This way it should fall down quicker but I´m not sure if it works and i would not recommend doing it because it´s less accurate

\$\endgroup\$
  • \$\begingroup\$ but LineRenderer is for 3d , I'm in a 2d game \$\endgroup\$ – Si Lawas Jul 24 '18 at 14:54
  • \$\begingroup\$ it should work anyway also if it´s 2D. One of the vector values must be zero then. also, line renderer is just a sprite which is rendered in 3D space as every other sprite \$\endgroup\$ – Pascal Lohscheidt Jul 24 '18 at 14:55
  • \$\begingroup\$ ok , I will try it I appreciate it \$\endgroup\$ – Si Lawas Jul 24 '18 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.