GameSalad

Wanting my actors to do different things from scene to scene

So basically in the first scene my actor moves left to right at 100, now in the next scene i need the actor to moving at a faster speed, this actor isnt already spawned in as the actor is spawned by the player.
TIA.

Comments

  • tatiangtatiang Posts: 11,293Member, Sous Chef, PRO, Senior Sous-Chef

    Use a game attribute for the speed. Then, in a different scene you can change the value of that attribute and your actor(s) will move at that speed instead.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • wmgaming505wmgaming505 Posts: 6Member

    thank you that seems to have done it.
    care to shine some light on this for me? My actors when colliding with each other add 1 to the players score, however i only want them to be able to give them this point once, essentially if two actors collide that have previously collided i dont want them to add another point to the score.

  • JapsterJapster Posts: 592Member, PRO
    edited May 31

    @wmgaming505 said:
    thank you that seems to have done it.
    care to shine some light on this for me? My actors when colliding with each other add 1 to the players score, however i only want them to be able to give them this point once, essentially if two actors collide that have previously collided i dont want them to add another point to the score.

    Not quite sure exactly what you're trying to stop without knowing something about the rules of your game, whether you have multiple actors on-screen capable of colliding simultaneously, but how about having an attribute for each actor, ie. an integer...

    eg. self.valueToAdd.

    Set it to '1' (integer)

    If ANY actor collides with another actor, they'll add valueToAdd to score, then set THEIR own valueToAdd to '0'.

    This will stop ANY actor that's been involved in a collision already, from adding '1' to the score.

    As I say, if you're looking for something different, like only adding 1 for each collision PAIR/GROUP, or having them score points for each unique other actor they collide with even after they've collided with another actor, then you'll need a bit more logic.

    ie. Like a GAME attribute instead, that the first colliding actor sets to 0 after adding it to score, so it's only added once, and then reset when no collisions are occurring, etc...

    ...and of course, if each actor can only collide ONCE, you could always spawn a none-colliding version underneath the currently colliding one, then destroy the colliding one...

    I'm sure the longer-term'ers will have a more elegant suggestion in time!

  • wmgaming505wmgaming505 Posts: 6Member

    yeah some great suggestions there thank you, I particularly like the idea of replacing the actor with an identical version just one that's missing the score code.

  • JapsterJapster Posts: 592Member, PRO

    @wmgaming505 said:
    yeah some great suggestions there thank you, I particularly like the idea of replacing the actor with an identical version just one that's missing the score code.

    Hey, no worries! - Glad it was of use! :smiley:

  • wmgaming505wmgaming505 Posts: 6Member

    little bit more on this as im still not able to get it to work.
    in my game you spawn donuts that move left to right, if you hit space they drop down and if they stack on top of each other they add +1 to the players score, but what i dont want them to do is be able to add another point to the score if they collide with each other again. they are the same actor in my game, you hit space and its just spawning identical donuts and i think thats why selfscore attributes arent working because if i change it in the code after the first two donuts collide the self attributes are telling it cant score anymore therefore all following donuts do nothing.

  • Simple Gamer ArtsSimple Gamer Arts Posts: 164Member, PRO
    edited June 4

    @wmgaming505 Ok, I'm just gonna wing it.

    In the Donut actor, create an attribute boolean called self.LOCK1 and leave it false (unchecked)

    ---Create a rule in the Donut actor---
    WHEN ALL CONDITIONS ARE VALID:
    • actor receives event: Overlaps or collides with actor of type Donut
    • attribute: self.LOCK1 is false

    CHANGE ATTRIBUTE: attribute: game.playerScore to game.playerScore+1
    CHANGE ATTRIBUTE: self.LOCK1 to true

    this should do the trick.

  • wmgaming505wmgaming505 Posts: 6Member

    holcy crap, id tried similar attributes to no avail but i think with your logic it might just work, TIA, i shall report back.

  • wmgaming505wmgaming505 Posts: 6Member

    so it may have worked but its created a bug, the donuts now fall through each other whilst holding the space bar, the space bar sets their motion.y to minus 100 and their motion.x to 0 and the player must also hold the space key for one second to spawn the donut.

  • Simple Gamer ArtsSimple Gamer Arts Posts: 164Member, PRO

    @wmgaming505

    Hi, I'll get back to you in a bit.

  • Simple Gamer ArtsSimple Gamer Arts Posts: 164Member, PRO
    edited June 6

    @wmgaming505

    ---Create a seperate rule in the Donut actor---
    WHEN ALL CONDITIONS ARE VALID:
    • attribute: self.LOCK1 is true

    CHANGE ATTRIBUTE: self.motionY to 0

    (this will stop the donut when it touches another donut even if spacebar is held down... I think) let me know.

Sign In or Register to comment.