The question is answered, right answer was accepted
help with player movement
how can i make my ball when i click a mouse button to go up and move left and when i click a mouse button again to go down and continue to move right? I tried whit gravity but it is not that good for controlling the ball .I use c#.
Answer by Statement · Oct 22, 2015 at 08:22 PM
Well, one way is to set the position manually.
Judging from your picture it looks like the ball is just following a rail.
Pressing mouse button changes rail from top to bottom and vice versa.
Your picture and your description doesn't add up. I wrote the example based on your written description so the ball goes left and right in addition to up and down. I made a revision which only goes right.
Ballmotion.cs (Moves only Right)
@Statement The script works but when the game starts the ball goes in the bottom rail and when it moves just right on bottom and top rail it jiggles up and down
Did you try my project?
It may be that you have other components influencing the behaviour, like a non-kinematic rigidbody which react to physics and/or gravity.
@Statement It works you have put the rails as a child object i haven't. But now i cant make the ball fall when it goes over holes in the rails.
@Statement The problem with gravity is that i need to increase it a lot to get fast vertical speed but it gets buggy when i set gravity over 200 the ball starts to go in the rails and i also want to make the horizontal speed to get faster but to go faster horizontally i need faster vertical speed and gravity gets buggy .So i though that there is another way to set speed but i m not good with program$$anonymous$$g so i didn't know how to do it.
Sounds like your game scale is all wacky. 1 unit should be 1 meter. A gravity of 200 is like, 200m/s^2 which is ridiculously high. If your rails are thin or simple mesh colliders, you'll experience tunneling problems (teleporting to other side of collider). You could also try to enable continous collision detection on the ball. Anyway, I suggest you post a new question with a specific question on how to solve your gravity problem if you want to do gravity. Include what you've tried, what doesn't work, what your desired outcome would be etc.
Follow this Question
Related Questions
Photon Player Mover Failure 1 Answer
Tracking transform position 1 Answer
Help with Vector3.Distance 0 Answers
Need Help With Having Player look at an object while stationary. 0 Answers
how to make forward relative to the view of the camera 0 Answers