how to change an actor to another actor when it collide with something.
ffarrukk
Member Posts: 2
Hi everyone, I need some help
i have spawn actors which are falling down from top of the screen. i have some kind of filters when falling actors touch the filter at the middle of the screen, actors are changing their colours depends on the filter colour. example, if the white actor touch the blue filter, actor has to be blue(NOTE: not as image) , every different colour actors have different behaviours, that's why i have to change the actor into another actor when it touch the filters. it is possible to change the image by change image behaviour but it is not changing the actor's behaviour.
i will be waiting for everyone's help . thanks
@tatiang
Answers
@ffarrukk Create a rule for the white actor where if it collides with the filter to spawn the corresponding actor (red, green etc) and then destroy itself. That should solve your problem.
"@IVER Industries" i thought of it, but when white actor touch the (red,blue,green..)filter, new colour actor has to get previous actor's velocity and position, like if it is falling down from top to bottom speed of 50 and destroy at the position x:160 , y:200, new actor has to start falling down from where previous actor destroyed and the same speed of previous actor.how could i have done this? can you send me a demo of it , or write what i have to do? thanks.
ill try and make a demo if it comes to that but if you want your different coloured actors to keep the behaviours like velocity, i would make a rule in each actor (only one colored actor is on the screen at a time right? ) to constrain its velocity and position. the constrain behaviour should update a global atribute for each self atribute such as x and y positions and liner velocity. however, if the actor is destroyed and and another instantly spawned it may not work. so, if the above does not work, you should create a timer that looks like, every-->0.01--->change attribute---->(name of global atribute e.g x position) to (self x position). I hope this makes sense @ffarrukk
@IVER Industries -- while that would work, it is not very efficient. Constraining is quite demanding on processing power.
@ffarrukk -- the alternative is to create a global attribute (real) for every piece of data you want to transfer (most likely linear velocity x & y, and angular velocity).
Once the collision happens, you will first save the actor's data into the global attribute, then spawn the new actor, then destroy the original actor.
Data such as position and rotation you will set in the spawn behavior.
In the spawned actor, the first set of rules will be to read the global attributes and change its liner velocity etc. to those values.
Voila! One write, one read and you're on your way!