Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
How do you simulate the trajectory of a grenade |
||||
|
I believe it was VP (Vegan Pete) who had a demo of a grenade-like weapon (mortar). I can't recall the name of his demo, but I will look in the forums and see if I can find it. |
||||
|
You could turn on physics and it will do that by itself pretty sure... - you just need to use either my physics drag n drop to pick and and throw it or use smnmhmdy's version... |
||||
|
I think VP probably used something similar to what Robo suggested in his answer, but I have not been able to find the demo. Sorry. |
||||
|
Yup, enabling physics will allow you to make parabolic missiles. Just give some velocity to the physics object on the Y axis and on the same time move it a bit forward. |
||||
|
You can try using a script to simulate a grenade throwing. I made a script that allow to do it: https://drive.google.com/file/d/... Edit: I forgot to say that you need to activate the physics at the publishing section. |
||||
|
Thanks for the mention Guest here's the quick demo I made a while ago, it's very basic (doesn't use any physics), just the built-in "rotate" action and "on proximity" action... https://www.ambiera.com/forum.php?t=9450 (It's the "Shoot in parabolic arc" download). I had wanted to make a "bouncing bomb" (with physics) for my first game "Cas-Evac" a couple of years ago - I tried for around a year to make a grenade, but failed, lol. I had tried around 7 different methods (shooting a blender-fbx animation/node-follows-path/ rotate-plane/ every-few-seconds+change position (animated)/ game-actor+follows-node/ real-time physics/ on-proximity-to-floor+change-position/ collide-when moved+affected-by-gravity /and various combinations of all these methods). They all partially worked but I couldn't get them perfect, so in the end I used the "rotating plane" method as a workaround for now. Personally, I think physics would probably look nicest, but I'm not skilled enough to get physics to work properly - with the "Shoot" action and physicsmade my game quite slow. It was "nearly finished", so I'll probably go back and Finish Cas-Evac at some point and see if I can make a better bouncing bomb. |
||||
|
I think, unless physics are used for other things too, it may be a bit of an unnecessary burden on the performance. A simple (non-homing/heat-seeking/etc) missile requires only two variables, or even only one: momentum. When fired, this is set to the max speed, eg. 10.0. Over time it slows down, and gravity becomes a significant factor. At some point it hits the ground. As there is actually no CC command to move a mesh in the direction it's facing, you would do this: (given we have stored the "Rotation" property of the missile in variables pitch, yaw and roll - tho roll we ignore) xyz be missile xyz x=x+sin(yaw) * momentum z=z+cos(yaw) * momentum y=y+sin(pitch) * momentum which is pseudo-code, so it must be tweaked. But certainly worth to have a function like: MoveNode(node,howfar). So let's say we got this working, then you would: as behavior executed every frame: MoveNode(missile,momentum); momentum *=.999; momentum -=0.001 if(momentum<0)momentum=0; // check whether ground impact... And again, missile has gravity on. Or alternatively, just subtract a static, small amount from y each frame. While a horizontally shot bullet in reality first flies a bit up, then after an arch down (called parabellum) I guess this detail can be skipped in a game. The amount it flies up is rather small. |
||||
|
BTW grenades and missiles are two different animals. This was more about grenades. |
|