ShiVa3D
lifetime of objects [SOLVED]
You feel lost? You don't understand how to use ShiVa?lifetime of objects
by Simon » 26 Apr 2012, 14:26
Greetings!
has shiva built in solution for automatically remove RuntimeObjects from scene(bullets) by time
has shiva built in solution for automatically remove RuntimeObjects from scene(bullets) by time
- Attachments
-
- bulletslifetime.JPG (55.98 KiB) Viewed 479 times
-

Simon - Expert Boarder

- Posts: 118
- Location: Russia, Siberia
Re: lifetime of objects
by broozar » 26 Apr 2012, 15:22
no. however, it is easy to implement. simply enter a postEvent at onInit for the bullets with a time delay you want to remove the bullet after.
Re: lifetime of objects
by Simon » 27 Apr 2012, 05:48
for each bullet need own AI?
would be better(for perfomance) store bullets handlers in table with fixed size mainAI and delete last when new bullet is appears (as FIFO stack)
but then how i will be detect that bullet hit the target?
would be better(for perfomance) store bullets handlers in table with fixed size mainAI and delete last when new bullet is appears (as FIFO stack)
but then how i will be detect that bullet hit the target?
-

Simon - Expert Boarder

- Posts: 118
- Location: Russia, Siberia
Re: lifetime of objects
by Simon » 27 Apr 2012, 05:52
Thank You! i think i understand
onInit= when i create bullet runtime object?
onInit= when i create bullet runtime object?
-

Simon - Expert Boarder

- Posts: 118
- Location: Russia, Siberia
Re: lifetime of objects
by DarkSoul » 27 Apr 2012, 08:32
It is easy. You need just a script with an event, no a script for each bullets, for instance "DestroyBullet", when you shoot the bullet, call this event from your script with postEvent. I recommend you store this event into the Main script or something into the user's scripts.
Send to the event the index of the bullet and then destroy it. You will use the index for know what is the object that you can destroy.
Send to the event the index of the bullet and then destroy it. You will use the index for know what is the object that you can destroy.
Re: lifetime of objects [SOLVED]
by broozar » 27 Apr 2012, 09:12
indeed you do not need an AI for every bullet.
if you indeed store your bullet object handles in a table, just postEvent() your destruction event every time when you create a new one, and add an extra parameter to the event handler: your object handle (or the corresponding place in your table).
if you indeed store your bullet object handles in a table, just postEvent() your destruction event every time when you create a new one, and add an extra parameter to the event handler: your object handle (or the corresponding place in your table).
Re: lifetime of objects
by Simon » 27 Apr 2012, 11:06
*and can be detected what bullet is collide with other collider? or for that i need to attach a sensor to bullet with specified index?
*also i will that bullet has own info about it's dangerous(how much hit point reduces from unit when bullet hits)
i want use for it sensor index for example 100015(1000 means bullet, 15 mean 15 hitpoint reduced if hit)
or may be better using for it tag for bullet?

*also i will that bullet has own info about it's dangerous(how much hit point reduces from unit when bullet hits)
i want use for it sensor index for example 100015(1000 means bullet, 15 mean 15 hitpoint reduced if hit)
or may be better using for it tag for bullet?
-

Simon - Expert Boarder

- Posts: 118
- Location: Russia, Siberia
Re: lifetime of objects
by broozar » 27 Apr 2012, 15:05
the ID solution you propose is nice, i would do that. avoid name tagging whenever you can.
8 posts
• Page 1 of 1

