grenades
Blitz3D Forums/Blitz3D Beginners Area/grenades
| ||
I have a game in which I need grenades. I can get one grenade to work(i.e. it flies in an arch and explodes on impact w/ another object.), but I need multiple grenades. I don't want to do the code over and over to accomodate each grenade, but I don't know how to use a type, array, etc. to do it. Any help? |
| ||
http://www.blitzbasic.com/b3ddocs/command.php?name=Function&ref=2d_cat |
| ||
This might help http://www.blitzbasic.com/Community/posts.php?topic=72799 |
| ||
how does the c\phys pivot create movement? |
| ||
TranslateEntity c\Mesh,EntityX(c\phys),EntityY(c\phys),EntityZ(c\phys) It's the same as having xspeed, yspeed and zspeed, except all rolled into one variable, with the additional advantage of being able to rotate it and move it in a given direction without having to worry about sine/cosine maths. |
| ||
ok, I see. now that the throwing-multiple-grenades function is good, how can I set up an explosion for each grenade? |
| ||
Same principle. Create a type for your explosion. Create a function to create an instance (like the newcube() function) and finally Create a function to update all explosions (like the updatecubes() function) Your NewExplosion function would probably accept either x,y,z co-ords and a size ie Function NewExplosion(x#,y#,z#,size) e.explosion = New explosion blah blah blah End Function Function UpdateExplosions() For e.explosion = Each explosion blah blah Next End Function |
| ||
two problems so far (w/ out the xplode). I can't move the point the grenades are thrown from or set a limit on the amount of grenades you can throw, they just keep on coming. once these are fixed there wont be a problem w/ the explosions. |
| ||
i don't understand your problem, code please :) |
| ||
Because I'm a caring sharing loving kinda guy... |
| ||
Not to sound idiotic, but, rob farley, how did you do that. I modified the code so that the launcher can move, and if still fires properly from the launcher. ( I don't have time to sift thru code:) ) I got a way to have a grenade-limit, so I'm good there |
| ||
You don't have time to sift through the code eh... Sounds more like you can't be arsed. Without sifting through the code you won't learn... however... There is a pivot (called muzzle) parented to the end of the barrel. The handle of the muzzle entity is passed to the NewGrenade function as 'Launcher' which exposes it's properties within the function. The start position of the grenade is then placed at the xyz of the that, likewise the trajectory of the grenade is picked up from the yaw, pitch and roll of the same passed entity. Likewise when the NewExplode is called the handle of the grenade mesh (c\mesh) is passed to it so the explosion happens at the point where the grenade is. Then the explosion itself is handled by exactly the same code which handles the updating of the grenades. The explosion is essentially just a bunch of grenades. Damn I'm being helpful today... I need to stop this before I make a habit of it. |
| ||
I might point out that I didn't have time to sift thru code at the time I posted. anyway, the world needs more helpful people, there's such a lack of them. sorry for using so much of your time. :) |
| ||
;)@Rob |