Check Collision & My Behaviors & Rambling

ToastKittenToastKitten Member Posts: 360
edited November -1 in Working with GS (Mac)
Instead of just having a collision event, could there be a behavior or attribute that you can use to check if there is a collision between objects?

Also, how can you add behaviors?

... Also, It'd be great if you could access things such as "other.Position.X" or "Actor1.Position.X + Actor2.Position.X"... You know, like being able to access any variable in the expression editor.

Thanks!

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Well, in the Rules, there are two conditions you have access to:

    "When Actor overlaps or collides with Actor of Type..."
    "When Actor overlaps or collides with Actor with Tag..."

    You would use them to check for collisions between different objects.

    If you need even more control, you can double-click on an Instance in the Scene to open its property inspector. On the left side, there are that Instance's attributes. You can give it a specific Name if you want. Then you have access to that as well:

    Rule
    When all conditions are valid:
    Actor overlaps or collides with Actor of Type Bullet
    self.Name = "Bob"
    -----Display Text "Bob has been shot!"
    ToastKitten said:
    ... Also, It'd be great if you could access things such as "other.Position.X" or "Actor1.Position.X + Actor2.Position.X"... You know, like being able to access any variable in the expression editor.

    Any Instance in the Scene has full access to every other Instance in the Scene. You can access every other Instance's attributes. You have the ability to either "listen" to them or set them. Prototypes in the Library do NOT have this ability.

    To test this, create two actors. Do not put any code in them. Drag an Instance of each one out into the Scene.

    Now, double-click on the first one.

    Click on the padlock to access that Instance's behaviors.

    Now add a Rule, like this:

    Rule
    When all conditions are valid:
    Touch is pressed
    -----Change Attribute: Current Scene/layers/Background/Actor 2/Color/Alpha To: 0.2

    That's just a quick example of one Instance controlling another.

    You can also listen for specific attributes, like this:

    Rule
    When all conditions are valid:
    Current Scene/layers/Background/Actor 2/Color/Rotation > 45
    -----Display Text: "Actor 2 has now rotated past 45 degrees!"

    There are three types of Attributes in GameSalad:

    Game Attributes
    Actor Attributes
    Scene Attributes

    Only unlocked Instances have access to Scene Attributes. An unlocked Instance has full control over the Camera as well.
    I have a demo project on my wall showing different Camera Tricks that you are free to dig around in.
    ToastKitten said:
    Also, how can you add behaviors?
    Thanks!

    I'm not sure I understand this. To add behaviors, just drag them over to the right from the list on the left. You cannot create your own behaviors.
  • ToastKittenToastKitten Member Posts: 360
    Thank you so much!

    When I say add my behaviors, I mean there's the little purple folder under "basic behaviors" labeled "my behaviors."
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Yeah, if you create a Rule set that you like and use a lot, you can drag it over there.

    But my understanding is that you currently cannot delete things from that folder, so use it with caution.

    I have found that copying and pasting Rule sets works just as well.
Sign In or Register to comment.