Having some difficulties with movement

ColorplayGamesColorplayGames PRO Posts: 69
edited November -1 in Working with GS (Mac)
Hello!

I'm currently working on a game where the default movement of the actor is to drift slowly down (it's a jellyfish!) To accomplish this I have different rules for moving right and left and under "Otherwise" for each I have a "Move" behavior that makes the actor drift down. So far, so good.

Now what I'm trying to do is add another actor into the game that causes the jellyfish to zoom upwards a little bit when they collide. I can get the zoom to happen by saying that when the jellyfish collides with the zoom object, for .25 seconds (run to completion) Move 90 degrees at a Speed of 500. I have the same default drift down behavior in the "Otherwise" section, but the jellyfish for some reason won't drift down after hitting the zoom object. (It will resume drifting if I move it right or left again.)

I've tried a bunch of different combinations of behaviors but can't seem to get this to behave the way I'm hoping. Any thoughts?

Thanks so much for your help,
Jenna

Comments

  • chosenonestudioschosenonestudios Member Posts: 1,714
    hmmm have you tried making the drift down rule in the same actor as the "zoom" one and then just loop the "down" rule?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I think I have a good idea o. What your trying to do, bu I'm not at home ight now, if your still having problems when I get home in a few hours, I'll up up a demo
  • ColorplayGamesColorplayGames PRO Posts: 69
    Hi Chosenone - yes, the rule for drifting down and zooming up when hitting the zoom object are both in the jellyfish object, though I'm not sure what you mean by looping the down rule. I'm trying to go through and simplify everything so I can figure this out but I'm running against a larger problem that I don't understand. If I give the jellyfish a general drift down behavior, this behavior stops once I move the jellyfish. Do I really need to put "drift down" in the "otherwise" section of all the rules or am I doing something wrong?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Move, move to, and change velocity will cancel out all other movements. So if you are using gravity to drift down any of the behaviors I listed will cancel it out. You must use accelerate or a rule with change attribute to change the x position.

    Here's what I do to mimic move in a way the does not cancel out gravity or jumping (zooming up in your case)

    when right key is pressed AND
    self.linear.X is < 250

    accelerate 0 degrees to scene with speed 2000

    when left key is pressed AND
    self.linear.X > -250

    accelerate 180 to scene with speed 2000

    This will feel like using move with a speed of 250, but will work with falling and zooming up.

    The only other thing I would play with is drag. When you move right and release the right button the jellyfish will have momentum and drag will effect this.
  • ColorplayGamesColorplayGames PRO Posts: 69
    Ah, I didn't realize they would cancel out other movements - that helps explain things!

    In your example, why do you require the linear velocity to be < 250 or > - 250? Is this to keep it within a maximum speed?

    I think I've narrowed the problem down to the timer I'm using. When I have "run to completion" checked, the movement works correctly but the drift down action doesn't kick back in. When I don't have "run to completion" checked the player just bounces up and down over the Zoom object - the zoom only happens when the player is colliding with the zoom object, then the drift kicks in, then it collides again, etc. I've been using the timer because I want the player to collide with the zoom object, then zoom up regardless of whether it's still touching the object.. is there a better way to do this? Sorry for all the newbie questions, I'm still learning my way around this program :)

    -Jenna
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    for the timer problem create a boolean attribute called zoom.

    Rule
    When collides with zoom object
    change game.zoom to true (1)

    Rule
    when game.zoom is true

    timer for 2 seconds (or whatever)
    Accelerate 90

    after 2 seconds
    change attribute game.zoom to false(0)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I use the <250 thing so I can have different max speeds for horizontal and vertical movements
  • ColorplayGamesColorplayGames PRO Posts: 69
    That fixed it! Awesome! Thank you so much for your help!!
Sign In or Register to comment.