Constant acceleration between two walls ... Interpolate?

sparkzillasparkzilla Member Posts: 152
edited November -1 in Working with GS (Mac)
I have tried two days of variations but I can't get this to work. Help!!!

I need the actor to accelerate and when it hits a wall I want it to continue to accelerate at the same rate in the opposite direction.

So say it starts accelerating at a rate of 10, I want it to continue to accelerate at 10 after it hits the wall but in the oposite direction. If I use bounce the actor will decelerate. If I change the restitution it decelerates then accelerates - nothing is constant.

I'm probably missing something very basic :-(

I need this to finish my game so any help most appreciated.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Try this. Have accelerate towards the left wall for .5 seconds to start it off. When actor collides with left wall change attrribute self motion linear x to 250. Then have another rule when actor collides with right wall change attribute self motion linear y to -250

    see how that works for ya
  • sparkzillasparkzilla Member Posts: 152
    Doing it that way wont I need a new rule for each speed increase?
  • b2iscoolb2iscool Member Posts: 135
    No just instead of changing it to 250 just make both walls either the same actor or in the same tag the and change the actors motion-linear velocity x to whatever you want it to start with put the actor like right to the right of the left create rule if your actor collides with walls then change self motion linear x to (-self motion linear x *1.5) experiment with the 1.5 but thats pretty much how i would do it
  • sparkzillasparkzilla Member Posts: 152
    Thanks, that works well and I will use it.

    There's no way to use the acceleration behavior?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    sparkzilla said:
    Thanks, that works well and I will use it.

    There's no way to use the acceleration behavior?

    you can have a attriubte for the direction. Call it direction (lol) when you collide with the left wall change direction to 0(so you move right) then when you collide with right wall change direction to 180 (so you move left) then have one accelerate behavior put your speed then in the direction select attribute direction and have it relative to scene.

    The other way will probably be alot smoother, try it out and see what you like though
  • sparkzillasparkzilla Member Posts: 152
    JohnP

    I must be missing something. My accelerating object does not seem to detect the wall. I opened a completely new project as a test with two actors, puck and wall.

    On the puck I have a rule:

    Actor receives event -overlaps or collides with - wall
    Accelerate speed 10 direction 180
    Otherwise
    Accelerate speed 10 direction 0

    Wall is not movable, restitution 0

    However, if I use Change Velocity behaviors instead of Accelerate the puck will detect the wall. Is this a bug?

    BTW, I would prefer to use the accelerate behavior because my actors currently use it and I do not seem to be able to make the velocity increment easily.
  • b2iscoolb2iscool Member Posts: 135
    Well personally the velocity is what i would do but whatever floats your boat make your pucks density lower and your walls density higher! hope it works
  • b2iscoolb2iscool Member Posts: 135
    b2iscool said:
    Its cause my idea is better haha its acceleration in a form just not a constant but this is like hockey or somethin?

  • sparkzillasparkzilla Member Posts: 152
    Nope. density doesn't work either. Try it and see if you get the same result.
  • sparkzillasparkzilla Member Posts: 152
    Still having a lot of trouble with this. I would appreciate more input regarding use of acceleration of actor after bounce/change direction. Thanks.
  • sparkzillasparkzilla Member Posts: 152
    Thank you. How would you increment the speed each time the actor hits a wall?

    EDIT: You don't think it can be done with the Acceleration behavior?
  • sparkzillasparkzilla Member Posts: 152
    I tried this solution with an increment for the speed each time the actor hits the wall . But it does not give any acceleration in between the walls- the speed is constant and then jumps when wall is hit.

    Do you know a way to make the actor accelerate smoothly between the walls?
  • sparkzillasparkzilla Member Posts: 152
    Hi, As regular readers may know I've been having a lot of trouble making an actor constantly accelerate between two walls. The reason this is so important is that it controls my main actor.

    I've tried the following:

    1. Accelerate behavior and Collide behavior -> bounce speed is not controllable
    2. Accelerate behavior and Collide Rule -> does not recognize collision
    3. Increment velocity when each wall hit -> works ok but does not give acceleration in between walls, giving jumps in speed that don't seem smooth.

    So now I am thinking that interpolate may work, but I can't seem to make it bounce between the walls. I can get it to go left to right, but not the right to left.

    Any and all ideas most appreciated.
  • sparkzillasparkzilla Member Posts: 152
    Thanks - any ideas on how to make it work? I may get so desperate I'll have to pay you!
  • sparkzillasparkzilla Member Posts: 152
    Thanks TshirtBooth but I need the ball to accelerate smoothly between the walls.
  • sparkzillasparkzilla Member Posts: 152
    I downloaded it. Your example shows the linear velocity incrementing by 10 each time it hits the walls. What I need is for it to smoothly go up so that the linear velocity number is always changing, as though I was using the accelerat behaviour

    Yours: 200 change direction 210 change direction 220 change direction 230

    Mine: 200, 200.1, 200.2, 200.3 -> 210 change direction 210.01, 210,02....220 change direction
Sign In or Register to comment.