Porabilic motion of a projectory

Blitz3D Forums/Blitz3D Beginners Area/Porabilic motion of a projectory

Chad(Posted 2006) [#1]
Could someone help me get a porabilic motion for my entity that's fired for my first person shooter?

I want it so when the player fires, they must arch their shot up for distance, kind of like this little art thing I've included:

[img /img]

Also, after the entity has hit an object set with collisions, is there a way to "freeze" the entity, or make it stop where it hits the collision and stay there? Another example of what I'm talking about:

[img /img]

Thanks!
Chad


octothorpe(Posted 2006) [#2]
1. Gravity is what causes physical bodies to move along a parabola. See this thread on implementing gravity: http://blitzbasic.com/Community/posts.php?topic=55946&hl=gravity

2. Set the object's velocity vector to 0 when you detect the collision. You'll need to loop through all your entities, checking each for collisions.


WolRon(Posted 2006) [#3]
Have you seen my FPS example?
In this section of code where the bullet is moved forward, also apply some downward movement to it.
For thisbullet.bullettype = Each bullettype			;iterate through all of the bullets
  MoveEntity thisbullet\entityhandle, 0, 0, 2			;move the bullet forward along the bullets Z axis
Next
could look like this:
For thisbullet.bullettype = Each bullettype			;iterate through all of the bullets
  MoveEntity thisbullet\entityhandle, 0, 0, 2			;move the bullet forward along the bullets Z axis
  TurnEntity thisbullet\entityhandle, .05, 0, 0			;rotate the bullet around its X axis to apply gravity
Next
Just adjust the turn movement according to how much gravity you want to apply.


octothorpe(Posted 2006) [#4]
No, no, no! Constant rotation will give you a circular arc and will yield highly unrealistic effects (especially if you shoot straight up!)


sswift(Posted 2006) [#5]
Chad:
I think you mean "Parabolic motion of a projectile". :-)

Octo:

No, no, no! Constant rotation will give you a circular arc and will yield highly unrealistic effects (especially if you shoot straight up!)



He's not telling him to...

...oh wait, he is.

WolRon:
You shouldn't use MoveEntity. You should use TranslateEntity.

First you translate your gun's normal into global space like so:
TFormNormal 0, 0, 1, Gun, 0

Then you multiply that normal by the speed of your projectile:

Bvx# = TFormedX() * BulletSpeed#
Bvy# = TFormedY() * BulletSpeed#
Bvz# = TFormedZ() * BulletSpeed#

Then each frame, you multiply 9.8 by the number of seconds that that frame took to render, (Secs#) and subtract the result from Bvy#.

Finally, you move the bullet with translateentity each frame, like so:

Translatentity Bullet, Bvx#*Secs#, Bvy#*Secs#, Bvz#*Secs#

Oh, and use AlignToVector Bullet, Bvx#, Bvy#, Bvz#, 3 to align the bullet's Z axis with the direction it is traveling in.


Shifty Geezer(Posted 2006) [#6]
Use ODE :p

Actually, Beginners forum. Scrub that!


WolRon(Posted 2006) [#7]
Well, I was just giving him a simple solution...


sswift(Posted 2006) [#8]
Me too. That simulation doesn't take into account mass, air resistance, or the spin of the projectile which determines if it will tumble or not! ;-)


WolRon(Posted 2006) [#9]
Oh, you're just too swift for me...


Chad(Posted 2006) [#10]
Well thanks all for your opinions and examples.. I appreciate it all..

Also, sswift, it is projectile, my bad!

Thanks,
Chad