Constrained actor block?
Hey folks we are working on a game which uses a pick up mechanic and we are a bit stuck on constraining.
Pretty much we have one actor which has been duplicated a number of times roaming the map waiting to be picked up by our main actor which is player controlled.
When these roaming actors collide with the main actor we constrain them to the x,y so they are suspend from the bottom of the main actor and are then transported to a goal location.
All of this works fine except for one factor! We need to limit the pick up number of these roaming actors to one per trip. Currently our main player controlled actor can pick up an unlimited numbers of these roaming actors.
I currently have a line of code running which tells any roaming actor constrained to the main actor that if collides with another roaming actor to release all actors causing them to drop and roam once gain. This causes a loop where if any of these actors overlap none can be picked up/constrained to the main actor. Messy! I know.
In our controls we also have a drop roaming actor button which the player can pressed at any time, not sure if this helps with a solution at all?
My overall question. Is there a way to stop an actor being constrained to our main actor if he is already carrying a roaming actor? Or a set up of swapping out one roaming actor for another if they collide allowing us to only carry one roaming actor at a time?
Sorry if I have not gotten this issue across clearly.
Comments
Try this. Create new att at the game say number. and create a rule at the actor
when actor collide (or take what code u use i dont know) change att game.number+1
then create another code if att game.number>5 (just saying the number put how much actor you want to use) stop collide (or take) .
i cant see the code but basic must be something like this.
Hey thanks for the reply, This issue is we are using the same actor duplicated for the roaming actors.
I have set up if main actor picks up one roaming actor we add Att scene.pickup+1
Then a rule on roaming actor:
if Att scene.pickup=2 do not constrain to main actor. This kills all constrains on roaming actors dropping everyone.
I am after a system if possible that blocks picking up roaming actors while carrying one or swaps them out for new ones replacing them on the main actor.
I think about this but its a little time taking.
Edit the prototype not main actor. Give main actor only basic rules.
At the prototype give this code to all actors with different numbers
if actor collide with main actor
change att pickup to 1
at the other rule
if game att = 1
(there is your following codes x,y etc etc.)
put another rule
if game att not 1
change game.x to self.x
change gamey to self.y
or something like this. But if you want to use duplicated actors you must edit prototype. If you edit main it rules all the actors not one.
Yeah I thought it would go this way. I was hoping there would be a way using duplicates because we have so many roaming actors. Cheers for the feedback man I will head back and have a look from another set up
Ok i got another idea create 3. actor and give this one following codes not duplicated ones and create at the game new att like follow or whatever = 0
then put this role to duplicates one
if this actor collide with main actor and
if att folow = 0
do
change att game.follow to 1
destroy this actor
then put this code roaming actor again
if this actor collide with main and
if att follow = 1
do
destroy this actor
and put this code to main actor
if this actor collide with roaming actor and
if att game.follow = 1
do
spawn actor 3. actor
position blah blah x y
and then put this code to main actor
if att game.follow=1 and
if this actor collide with roaming actor
do
spawn actor roaming actor
position at the back of the actor (for this you can use 3. actors position x,y +5 or -5 where do you want to spawn it.
with this when your lone actor take first actor it changes follow to 1 and 3. actor start to follow your actor, after every time you collide with roaming actor if your att follow = 1 it destroy colliding roaming actor and spawn new one at the back. this one will looks like it takes new one and left old one at the behind i hope so . i am not at my computer so i never try this
edit : there was a little bug i change the codes
I may have missed something but it seems like you're overthinking this. Create a boolean attribute called game.carrying and set it to false. Create a boolean attribute in the roaming actor called self.following and set it to false.
In the roaming actor, when it collides with the player actor, if game.carrying is false then change self.following to true and then change game.carrying to true. Also in the roaming actor, when self.following is true, constrain it to the player's X and Y position. When the player drops the roaming actor, change self.following to false and then change game.carrying to false.
Of course, the roaming actor may then still be in contact with the player actor and will immediately attach itself again. To prevent this, you might choose to destroy the roaming actor when it's dropped or move it somewhere else or set a self boolean attribute such as self.used to true and add that as a rule condition to prevent it from being picked up again.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User