Destroy After Collide + Linking Multiple Actors - Two Questions
![Mack_Dundee](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hello, this is my first post. I've spent that past couple of weeks going over every tutorial I can find. When I've been stuck trying more advanced things, it seems there was always another tutorial or forum post with my answer. The Gamesalad community seems to have plenty of members who are very generous with their time and help. I hope that someday I am able to contribute as well.
Anyway, there are a couple of questions that I haven't been able to find help on. Sorry for the longwinded nature of these questions, but I wanted to air on the side of clarity. Any suggestions or answers is much appreciated. Thanks ahead of time.
1) I would like to make a game where the player must go from point "A" to point "B" while touching a series of platforms on the way. The challenge is that the player must touch every platform only one time, as each platform is to disappear after the player moves off of it. (Thus, there is strategy involved in choosing a path.)
My first issue is making a platform/actor disappear AFTER the player moves off of it. I can make a platform actor disappear on overlaps or collides (but then the actor just immediately falls through the spot of the touched platform) and I can make it disappear with a key press (but having the actor disappear on a simple press of the down arrow will just make all of the platforms disappear with any down arrow touch regardless of whether or not the player touches the platform's surface). Again, how do I allow an actor to move to a spot and have that spot disappear upon moving to the next spot?
My guess is that there may be a way with a timer that is activated/triggered upon touching the platform that can then check the platform at short intervals and once the player moves on to a new spot, the previous platform could be destroyed. Does that make any sense? Is there a wiser method?
2) How do I make the player stand below the top of a 2d platform? For instance, I was thinking of making these destructible platforms appear 3d with some basic single point perspective techniques. The two methods that come to mind would be if Gamesalad has some sort of control for where collision occurs on the platform (ie, -75 from top using some math value entered somewhere) or to use two separate actors for each platform. The later would involve one actor as the actual point of contact between player and platform and a second actor as the non-collision 3d faked "perspective."
To clarify, lets say the desire is to have the player standing midway through a green box. The entire green box area could be covered by one non-collision actor. Above that, a second actor consisting of a smaller size with the same color green could be located at the midway point of the first non-collision actor. Because the color of both boxes is the same, the illusion would be that their is only one large green box and that the player is standing in the middle it. The problem with this method? How would I get both the larger and smaller green boxes to disappear together after the player moved to a new area?
Maybe I've missed it, but I can't seem to figure out how to link two platform actors (or any other type) together. For instance, is there a way to shoot a target and eliminate both the original target and another actor? The "Destroy" behavior only seems to allow "Destroy this actor." With the example above, how would I destroy both green boxes. Or is there a way to make the non-collision green box actor invisible as this would also seem to do the trick?
Any help or suggestions is appreciated. Thanks for your time.
Anyway, there are a couple of questions that I haven't been able to find help on. Sorry for the longwinded nature of these questions, but I wanted to air on the side of clarity. Any suggestions or answers is much appreciated. Thanks ahead of time.
1) I would like to make a game where the player must go from point "A" to point "B" while touching a series of platforms on the way. The challenge is that the player must touch every platform only one time, as each platform is to disappear after the player moves off of it. (Thus, there is strategy involved in choosing a path.)
My first issue is making a platform/actor disappear AFTER the player moves off of it. I can make a platform actor disappear on overlaps or collides (but then the actor just immediately falls through the spot of the touched platform) and I can make it disappear with a key press (but having the actor disappear on a simple press of the down arrow will just make all of the platforms disappear with any down arrow touch regardless of whether or not the player touches the platform's surface). Again, how do I allow an actor to move to a spot and have that spot disappear upon moving to the next spot?
My guess is that there may be a way with a timer that is activated/triggered upon touching the platform that can then check the platform at short intervals and once the player moves on to a new spot, the previous platform could be destroyed. Does that make any sense? Is there a wiser method?
2) How do I make the player stand below the top of a 2d platform? For instance, I was thinking of making these destructible platforms appear 3d with some basic single point perspective techniques. The two methods that come to mind would be if Gamesalad has some sort of control for where collision occurs on the platform (ie, -75 from top using some math value entered somewhere) or to use two separate actors for each platform. The later would involve one actor as the actual point of contact between player and platform and a second actor as the non-collision 3d faked "perspective."
To clarify, lets say the desire is to have the player standing midway through a green box. The entire green box area could be covered by one non-collision actor. Above that, a second actor consisting of a smaller size with the same color green could be located at the midway point of the first non-collision actor. Because the color of both boxes is the same, the illusion would be that their is only one large green box and that the player is standing in the middle it. The problem with this method? How would I get both the larger and smaller green boxes to disappear together after the player moved to a new area?
Maybe I've missed it, but I can't seem to figure out how to link two platform actors (or any other type) together. For instance, is there a way to shoot a target and eliminate both the original target and another actor? The "Destroy" behavior only seems to allow "Destroy this actor." With the example above, how would I destroy both green boxes. Or is there a way to make the non-collision green box actor invisible as this would also seem to do the trick?
Any help or suggestions is appreciated. Thanks for your time.
Comments
Then, in the master actor,
rule:
if collide with main-actor
change player.leave to 3
otherwise
player.leave = 0
also,rule
if attribute player.leave = 3\
destroy
and then edit every actor platform on scene and change the 3 to a 4, 5, 6, etc....
and always have otherwise = 0
- Jeff
- Jeff
Jeff (or anyone else), maybe I'm too much of a novice to understand your answer to #1, but I'm not sure how to get the incremented value of the platform to 2 by jumping away from the platform. The only way I can get the platform to disappear is by jumping on it twice and using an overlap/collision as the detection method.
Is it possible to try something along the lines of using a timer (or some other method) to both detect if the platform has a value of 1 (from the initial player landing) as well as no player overlap/collision with the platform (thus waiting for the player to jump away and leave the platform unoccupied)?
I hope that isn't too confusing.
I hope this helps some one down the line. I'll try and be very specific so as to make it as simple as possible. If someone can think of a better method, please let me know.
Here's the walkthrough:
1) Create a game attribute called "platform" (or whatever you'd like) using the boolean type. (Minus the quotations, of course.)
2) Create two actors called "Block" and "Player."
3) Double-click on the actor "Block" to edit.
4) Create a new rule and include the following: Actor receives event - overlaps or collides - with actor of type - Player - add a change attribute behavior (from the basic behavior list) - change attribute: game.platform - To: True
5) Drop a Timer window below the change attribute listed above (but still in the same rule) from the basic behaviors list and include the following: Every 0.2 seconds - Drop a new rule in the space between "Run to Completion" and "Otherwise" - Actor receives event - Overlaps or collides - with actor of type - player - THEN add a new rule in the otherwise section - Attribute - game.platform - True - FINALLY just below that (and above "Otherwise") add a Destroy behavior.
6) As for the Player actor and his movements, there are plenty of tutorials to help you there.
Anyone have any suggestions on how to improve the above method?
1) Create a game attribute called "platform" (or whatever you'd like) using the boolean type. (Minus the quotations, of course.)
2) Create two actors called "Block" and "Player."
3) Double-click on the actor "Block" to edit.
4) Create a new rule and include the following: Actor receives event - overlaps or collides - with actor of type - Player - add a change attribute behavior (from the basic behavior list) - change attribute: game.platform - To: True
5) Create a new Rule - Drop a Timer attribute into the rule - Every 0.2 seconds - Drop a new rule in the space between "Run to Completion" and "Otherwise" - Actor receives event - Overlaps or collides - with actor of type - player - THEN add a new rule in the otherwise section - Attribute - game.platform - True - FINALLY just below that (and above "Otherwise") add a Destroy behavior.
6) As for the Player actor and his movements, there are plenty of tutorials to help you there.
4) If player actor collides with platform actor AND platform attribute is equal to 0, change platform attribute to be 1. This is for the first platform. The second platform would use 1 and 2, the third platform would use 2 and 3, and so on.
5) If platform attribute is greater than 1, change opacity to 0 (to make it invisible) or destroy/move actor (if you want the platform entirely gone). This is for the first platform. The second platform would use 2, the third platform would use 3, and so on.
Say the player starts on the ground and the platform attribute is 0. The player jumps to the first platform (the platform attribute is incremented to 1) and can stay there until they jump to the second platform. This includes jumping up and down on the first platform (it only increments the platform attribute on the first jump). When the player jumps to the second platform and lands on it, the platform attribute is incremented to 2 (and again, only on the first jump) and the first platform disappears (invisible, move/destroy, whichever way you want). Obviously, you can change it if you want it where jumping up and down on the same platform makes it disappear but that would just require slight changes to the above.
You probably want to avoid having timers on each platform as you may encounter some performance issues if you have a lot of platforms. If you do need to go the timer route, use interpolate or self.time.
- Jeff
In my Block actor's edit field I have the following:
A) Rule - Actor event - collides/overlaps - type -player
change attribute - game.platform - to: 1
(Please note that I changed the game attribute "platform" to an integer from a boolean as listed in the above walkthrough.)
Destroy This Actor
Using the above, when collided/overlapped by the player the block actor does not disappear. How do I assign numbers for each block actor mentioned above (ie - 1, 2, 3, and so on)? Is that where the problem lies?
Platform Actor #1:
A) Rule - Actor event - collides/overlaps - type -player
change attribute - game.platform - to: 1
Destroy This Actor
Platform Actor #2:
A) Rule - Actor event - collides/overlaps - type -player
change attribute - game.platform - to: 2
Destroy This Actor
Platform Actor #3:
A) Rule - Actor event - collides/overlaps - type -player
change attribute - game.platform - to: 3
Destroy This Actor
Platform Actor #4:
A) Rule - Actor event - collides/overlaps - type -player
change attribute - game.platform - to: 4
Change attribute - game.win - to: 1 (or whatever you want to happen)
Let's say there are four platforms with the 4th one being the goal/win platform. The player starts on the ground and game.platform is 0. The player jumps on platform actor #1 and game.platform changes to 1. The player jumps on platform actor #2, game.platform changes to 2 and so platform actor #1 is destroyed. The player jumps on platform actor #3, game.platform changes to 3 and so platform actor #2 is destroyed. The player jumps on platform actor #4, game.platform changes to 4 and so platform actor #3 is destroyed and the player wins the game.
- Jeff
One last question, is there a way to use the same method so that the player has more than one route to destroy the platforms? Let's say we have a level where the user can choose to touch Platform #3 before Platform #2 and still complete the puzzle. Is there an easy way to make the player have to touch each platform, but allow for different routes?
By the way, if you're sick of answering my questions I certainly understand. Regardless, I'll keep an eye out on your profile and I'll be sure to buy any apps you release and give you a positive review.
In regards to your last question, you could try something like this:
Platform Actor (all):
A) Create a self attribute (integer, default value = 0) called "save" and a self attribute (boolean, default value = false) called "activate".
change attribute - game.platform - to: game.platform+1
change attribute - self.save - to: game.platform
change attribute - self.activate - to: true
C) Rule - attribute - game.platform - > - self.save AND self.activate = true
Destroy This Actor
So when the player jumps on any platform, it becomes activated (via self.activate = true) and the current game.platform value gets saved into self.save. Then when the player jumps on another platform, game.platform will increment by 1 but it will then not equal the previous platform's self.save value AND because that platform was already activated, the previous platform will be destroyed. You should be able to use this for all the platforms without changing it AND be able to jump on the platforms in any order. Without the logic for self.activate, when the user jumped on the first platform, all the other ones would be destroyed because game.platform > self.save.
Thanks for the generous offer (and lord knows my app could use some sales! ha) but I like to pay it forward, not back. If I can be of help to someone, that's great because others helped me either directly or by posting templates/videos that I could learn from. I'm sure you'll be able to do the same and we can keep the GS community a friendly and helpful resource for GS developers.
- Jeff
I wasn't able to get things to work as you listed in your last post. Whenever I entered the "C" information as stated above, the player actor wouldn't even move at all. Is the following item from "B" correct?
change attribute - self.save - to: game.platform
How does the above effect the self.save and what is it doing to game.platform?
I did some fooling around and the only way I was able to make things work was by using the following:
A) Create a self attribute (integer, default value = 0) called "save" and a self attribute (boolean, default value = false) called "activate".
change attribute - self.save - to: 1
change attribute - self.activate - to: true
C) Rule - Actor receives event - overlaps/collides - actor - player
Otherwise:
Rule - attribute - self.save - = - 1
attibute - self.activate - = - true
Destroy This Actor
By the way, your last post really put into perspective something I had previously failed to wrap my head around. Even though I had looked over plenty of example templates, I was only looking at adding atributes at the game level as opposed to the actor/self level. Your last response really hammered that logic into my mind. Again you have been a great help, Jeff.
- Jeff
If you want, I can email you the test project I made.
- Jeff
I'd like to eventually turn this into a free template for new users and I was doing all sorts of tests on controlling various aspects of collision between actors that I ended us switching my environment from one where the player was jumping on top of a platform to one where the player was actually standing/overlapping blocks. I was testing things such as jumping through one block to a third block using Move To and a timer (as well as a few other methods) so that the middle block wouldn't be affected (or destroyed) even though the player would pass through the middle block on the move to action.
To try and clarify, let's look at things as a linear progression from A to C like this:
A-B-C
The player would have the option of jumping from A to B with A being destroyed. Next, the player could jump from B to C, with B being destroyed. Conversely, another option would allow the player to jump from A directly to C (passing through B without destroying it) where only A would be destroyed. Finally, the player could jump from C to B with C being destroyed.
I was trying to work on various methods that could be expanded for platform and puzzle games. I'm very sorry that I failed to state that I had changed the dynamic and, because of my mistake, you put in the time to test things. Thanks a lot for the effort though. I really appreciate it.
Still, if you would email me the test project at JJCoolbean73[at]hotmail.com I would really like to take a look at it. I'm sure there are some things I can gleam by just looking at your project. Also, if you are curious, I can send you my test project right back by replying to your email attachment with one of my own. Just let me know in the email if you want me to send it.
- Jeff
- Jeff