Hello,
I’m trying to fix this problem but just can’t find a tutorial about the subject (maybe wrong keywords IDK)
I the Game Engine, I have an object that I want to see for a time. Once the time period has elapsed, it moves to another layer. While on that layer, it moves to another position and reappear only for a time. Nothing fancy.
When I press “Alt-A” this scenario’s working fine. But when I press “P”, the object that should disappear don’t and stays there the whole time. :mad::spin:
I’m new to the BGE but I learned long ago that the best and quickest way to learn something new is to try and solve other people’s problems so here goes:
Forget animating the layer change. I’ll take the other people’s word for it that it doesn’t work in the BGE.
Instead, use an End Object and Add Object Actuator to make the object disappear and reappear.
From what I can gather, ending an object is straight forward. When a condition is met, the actuator fires and the object disappears. To add an object, I think you need a placeholder, usually an empty, and connect the actuator to that with a necessary condition. The object will appear wherever the empty is so if you move the empty around, the object will appear in different place. Alternatively you could have a bunch of pre-set empties adding objects when they need to. You can even have a starting speed so the object appears moving (like bullets)
For this to work, the Add/End object (the thing you want to appear and disappear) needs to be placed on a hidden layer before pressing P.
Unfortunately, I don’t know much about triggering conditions like “Time” but hopefully you’ve got that covered.
Hmmm… Depending on what you’re trying to do, another way to do this may be to use the timer property and a property sensor waiting for a certain value. Link the property sensor to a visibility actuator to make the object invisible. Then you could perhaps use a motion actuator to move the object before making it visible again.
Not sure how easy this would be to sort out, but might be an alternative if it’s not possible to move between layers.
It might be easier to use the visibility actuator and setPosition() in a Python script, if you know how to do that.