How do you get a moving actor to stick to walls?

GuardianGuardian Member Posts: 54
edited November -1 in Working with GS (Mac)
Hi guys,

I have an actor that I want to stick to another actor when it collides with it. For instance if it hits a wall it should stick to where it hit.

I tried changing it's movable attribute to false, but it just carries on falling. :(

-Guardian

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
    Change attribute self.velocity.x to zero,
    Change attribute self.velocity.y to zero.

    If you have gravity in your game, change that to zero as well.
  • lildragnlildragn Member Posts: 105
    What if you simulate gravity with acceleration? (on a per actor basis). This is what I have.

    ~t
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Then put your acceleration behavior into the otherwise section of a rule that says if Actor overlaps or collides with Walls.
  • theCodeMonsterstheCodeMonsters Member Posts: 359
    Increase the friction and set volicties to 0 when hits. If you want some sort of animation. then have him gradually go to 0.
  • GuardianGuardian Member Posts: 54
    Ok cool, that all makes sense.

    I have changed the linear velocity x and y to 0 on the actor.

    I do use gravity, but how do I change the gravity? I can't seem to find it in the list of attributes on the 'Change Attribute' behaviour.
  • lildragnlildragn Member Posts: 105
    To change the gravity you have to create an empty actor, place it on the stage and "unlock" it. You'll be able to access all "Current Scene" attributes...

    Woot! my first helping post :)

    ~t
  • GuardianGuardian Member Posts: 54
    Perhaps I'm being really dim. Sorry, I am really new to GameSalad (not game dev).

    I created an empty actor. I placed it on the stage (I assume that meant in the scene) and well I couldn't see an "unlock" option.

    Where is this option? :S
  • GuardianGuardian Member Posts: 54
    So I have now assumed you meant double click it in the scene and then unlock.

    This didn't work. :(
  • lildragnlildragn Member Posts: 105
    Hey no prob, I'm 2 weeks into GS myself, so we're all learning at some level here. Ok I'm about to publish my efforts shortly (barring noob mistakes) but once you unlock the actor on the "stage" inside there what I've done is create a rule to determine when I should switch the values of the gravity to 0 then back up to 600 (in my case). So if you drag a "change attribute" behavior out to the rules page you should be now able to access the Gravity X/Y attributes and then set their values.

    Give it a go.

    ~t
  • GuardianGuardian Member Posts: 54
    Ok ok, Gotcha. So it's all working now.

    Only instances have access to the scenes attributes. So you meant add the actor to the scene, then unlock it and then you can use 'Change Attribute' to change the scenes attributes.

    Thank you guys :D
  • lildragnlildragn Member Posts: 105
    Ok just published my first "game" it's just basically a demo demonstrating what we spoke about here. There's some funky stuff left in there but at least you get to see things "working"

    Search for Beyond the Basics in the New section of the launchpad and it should pop up or go here http://gamesalad.com/game/45386

    Woot! For some reason though the publishing part of the app didn't allow me to choose an image, they were all greyed out.

    ~t
Sign In or Register to comment.