Destroy and Respawn Timer Question

Hello,

I would like to ask you how exactly I can make this combination: When Player collides or overlaps with Ground Tile, the ground tile destroys itself after 2 seconds and then 3 seconds after destroying to respawn itself on the same spot.
However, I got an idea how to do that exactly but I want you to assess its effectiveness.
-------
Create integer {Jump} set to 1

BEHAVIOURS OF PLAYER

[Rule]
If Player collides or overlaps with Ground Tile - Change Attribute {Jump} to 0

BEHAVIOURS OF GROUND TILE

[Group] (I haven't used the Group option yet but I think I know what is it for)
-[Rule]
When {Jump} is 0
--[Timer]
After 2 seconds
Destroy Ground Tile
[End Group]

[Group]
-[Rule]
When {Jump} is 0
--[Timer]
After 5 seconds
Change Attribute {Jump} to 1
[End Group]

[Rule]
When {Jump} is 1
Spawn Actor - Ground

(((Either destroy or change image to No Image so it wont be any obstacle)))

------
-Are those behaviours correctly created?
------

One more
Q: if constructed that way should I apply those behaviours to EACH ground tile(instance) within the game?Otherwise if it is set to (prototype) it will spawn ground tile on top of other ground tile every 5 seconds.
OR
Is the best solution not to use Spawn Actor behaviour but Change Image behaviour?

----
Sorry for the long thread but I want your opinion.

Rate this 'engine' or suggest one.

Thank you



Comments

  • SylvannusSylvannus Member Posts: 21
    Bump.
  • JarrenHJarrenH Member Posts: 206
    When you destroy an actor, it does just that, destroys it. You cannot reference it and any other behaviors or rules following the destroy will never happen, meaning it can't spawn itself once its destroyed! You are almost better off setting its alpha value to 0 to make it appear transparent. Unfortunately your actor can still collide with it... some more expert help might be needed in that respect.

    FYI about groups, It really doesn't change how the code works, but rather helps you to organize your code to make it more readable.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Its probably easier to move the tile off-screen where it won't be seen and wont be colliding with anything. Then when you want it back, simply stick it back in place. Something like this:

    When collides or overlaps with actor of type (Whatever)
    -- Change Attribute: self.savedPosition To: self.Position.X
    -- Timer -- After 2 Seconds
    ---- Change Attribute: self.Position.X To: -200
    -- Timer -- After 5 Seconds
    ---- Change Attribute: self.Position.X To: self.savedPosition

    Note: better check "run to completion" on each timer.
Sign In or Register to comment.