Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Getting Started

lifetime of objects  [SOLVED]

You feel lost? You don't understand how to use ShiVa?

lifetime of objects

Postby Simon » 26 Apr 2012, 14:26

Greetings!
has shiva built in solution for automatically remove RuntimeObjects from scene(bullets) by time
User avatar
Simon
Expert Boarder
Expert Boarder
 
Posts: 112
Location: Russia, Siberia

Re: lifetime of objects

Postby 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.
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3579
Location: Berlin - Germany

Re: lifetime of objects

Postby 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? :idea:
User avatar
Simon
Expert Boarder
Expert Boarder
 
Posts: 112
Location: Russia, Siberia

Re: lifetime of objects

Postby Simon » 27 Apr 2012, 05:52

Thank You! i think i understand
onInit= when i create bullet runtime object?
User avatar
Simon
Expert Boarder
Expert Boarder
 
Posts: 112
Location: Russia, Siberia

Re: lifetime of objects

Postby 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.
User avatar
DarkSoul
Gold Boarder
Gold Boarder
 
Posts: 221
Location: Spain

Re: lifetime of objects  [SOLVED]

Postby 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).
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3579
Location: Berlin - Germany

Re: lifetime of objects

Postby 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?

:idea:
User avatar
Simon
Expert Boarder
Expert Boarder
 
Posts: 112
Location: Russia, Siberia

Re: lifetime of objects

Postby broozar » 27 Apr 2012, 15:05

the ID solution you propose is nice, i would do that. avoid name tagging whenever you can.
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3579
Location: Berlin - Germany


Return to Getting Started