I found there seems to be something wrong with the Accelerate behaviors

My actor is moving at speed 50, and I want it to accelerate with 100 acceleration.
So, I made rules like this:
-----move 50 additive
-----when w key is pressed
do accelerate 100
The preview result is that , the actor does not accelerate at all.

Then I changed the rule like this:
-----when w key is pressed
do accelerate 100
else move 50 additive
The preview result is that,the actor is moving at 50. When w is pressed, the actor stops,and then begines to accelerate.

Please help me to solve this problem. Thanks a lot.

Comments

  • vectorstudiovectorstudio Member Posts: 50

    accelertate + accelerate, the actor would not stop
    move + accelerate,the actor would first stop,and then accelerate

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    Change the actor's Linear Velocity X attribute to 50.

    Then add this rule:

    When W is pressed
    Interpolate linear velocity X to 100
    Otherwise:
    Interpolate linear velocity X to 50

    (I am assuming you are moving in the X direction, but change that to whatever you need)

  • vectorstudiovectorstudio Member Posts: 50

    @Socks said:

    It's a plane game, an aircraft is moving freely in the screen.
    I tried this method,using interpolate behavior. And I found that the actor is moving for 1 second,then stopped. Once I press "w", it moved again and stop after 1 second.

    Then I removed all the rules and tried like this to test the interpolate behavior:
    ----interpolate self.motion.linervelocity.x to 50 for 5 secends using liner function
    ----move in direction 0 relative to scene at speed 50.
    But the Preview result is that the actor accelerate from 0 to 5 in 5 seconds,and then stop.

    May be the behaviors in GameSalad can't be used together.

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @vectorstudio said:
    It's a plane game, an aircraft is moving freely in the screen.

    Ah! I see, I thought it was a platformed type movement (left to right).

    Maybe try this:

  • vectorstudiovectorstudio Member Posts: 50

    @Socks said:

    Thanks so much.
    Inspired by you, I found out a good way.

    add a attribute to actor, speed=50
    move (speed)
    when “w”key is down
    do interpolate (speed)to 100 in 2 seconds
    else interpolate (speed) to 50 in 2 seconds

    It's very good.

  • SocksSocks London, UK.Member Posts: 12,822

    @vectorstudio said:
    It's very good.

    I think you will find that from time to time you will get a glitch using this method as if an interpolate behaviour is triggered it will run until it is finished.

  • vectorstudiovectorstudio Member Posts: 50

    @Socks said:
    I think you will find that from time to time you will get a glitch using this method as if an interpolate behaviour is triggered it will run until it is finished.

    Oh,yes,Thanks to remind me.
    It really has some unexpected behaviour.
    When I press w key for the first time, even it's a short time, the aircraft will accelerate to 100.
    But after the first time, it works fine.

    I think i should consider it later.

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @vectorstudio said:
    When I press w key for the first time, even it's a short time, the aircraft will accelerate to 100.

    Yes, because the interpolate will always finish once it has been started, you will also get this problem (very occasionally) after the first time as well. Try my code above (the screenshot) it works fine.

Sign In or Register to comment.