|
Hi, I'm new here and also new to unity. I have done some web development and know a little javascript so I think that will be my language of choice. Basically I want to create a game where when you press the button, a ball will travel on a trajectory and then hit the ground and roll to a stop. The keys to this is that the ball slows down when it hits the ground and doesn't roll too far. So far I have created a sphere on my terrain. I have been searching for how to launch projectiles and moving objects to a position but I have not found any useful code. If someone could point me in the right direction or offer a sample of what my script will need to look like to achieve this I would be very greatful. Thanks Steve
(comments are locked)
|
Mike thanks for your answer. I must admit I am a little more newb than I would like. Using your solution, how would I specify the trajectory for the ball. It would reach its highest point at about 80% of its distance. Would i be asking too much to get a sample of what the script would look like? Thanks again
Jun 19 '12 at 07:34 AM
binga30
Although rather brief on details this answer got me what i wanted.
Jul 09 '12 at 10:08 AM
binga30
(comments are locked)
|
|
You're gonna need to use some Physics for this (hopefully I'm not a Unity moron, and Unity actually has realistic Physics calculations). Assuming we have that set relation of 80%, here's what it looks like (in C#, because I don't write in Javascript on Unity since it's different from the ECMA standard): I'm HOPING this works. I haven't tested this and I haven't worked with the Physics part of Unity (so I can't guarantee what force in
(comments are locked)
|

If I understood you right the main point is the slowing down of the ball?
Just attach a rigidbody to the ball and the rest should work... For instantiating an Object look here:
http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html
I think I might have replied in the answer box lol.
Anyway yeh the slowing down is important, as if the effects of the terrain when the ball lands, ie- the ball would roll down a slope.
However my first step is to get the ball launching into the air on a trajectory when you press click a button or press a key.
Thanks for your link, I am not familiar with the instantiate methods. Is this how you make projectiles fly through the air to a designated position?
Thanks again