Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
missiles

lcm
Registered User
Quote
2021-12-25 15:03:46

How do you simulate the trajectory of a grenade


Guest
Guest
Quote
2021-12-27 20:22:05

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.


Robo
Guest
Quote
2021-12-28 00:31:07

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...


Guest
Guest
Quote
2021-12-28 06:44:26

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.


just_in_case
Moderator
Quote
2021-12-28 16:01:48

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.


kaelgodoy
Registered User
Quote
2021-12-30 23:54:03

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.


VP
Guest
Quote
2022-02-23 07:57:18

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.


csp-games
Guest
Quote
2022-02-24 22:28:34

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.


csp-games
Guest
Quote
2022-02-24 22:31:27

BTW grenades and missiles are two different animals. This was more about grenades.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact