Porabilic motion of a projectory
Blitz3D Forums/Blitz3D Beginners Area/Porabilic motion of a projectory
| ||
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 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 Thanks! Chad |
| ||
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. |
| ||
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 Nextcould 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 NextJust adjust the turn movement according to how much gravity you want to apply. |
| ||
No, no, no! Constant rotation will give you a circular arc and will yield highly unrealistic effects (especially if you shoot straight up!) |
| ||
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. |
| ||
Use ODE :p Actually, Beginners forum. Scrub that! |
| ||
Well, I was just giving him a simple solution... |
| ||
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! ;-) |
| ||
Oh, you're just too swift for me... |
| ||
Well thanks all for your opinions and examples.. I appreciate it all.. Also, sswift, it is projectile, my bad! Thanks, Chad |