"Move to" Problem

Hello! I found out the "interpolate" and "collide" don't work together. I wanted to use a "Move to" behavior but it's not really going to the position I want it to unlike the interpolate. Is there anyway possible you can't make the interpolate and collide work together?

Comments

  • pHghostpHghost London, UKMember Posts: 2,342

    @http_gamesalad‌ -- Can you explain a bit more about what exactly you are trying to do?

    It is possible to make them work together with a workaround, but it does depend on the situation.

    If you can share a bit more about the collision, it will help a lot. Information that will be handy for helping you:

    The two items colliding, are they both moving, or only one of them? If both are moving, is it with interpolate, both of them?

    What happens after -- i.e. what is the intended reaction of the crash? Does any of the actors get destroyed? Do they only bounce off each other? Give as much detail as you can and are willing about what you WANT to happen. The more specific you can be, the more help you can get.

    EXAMPLE:
    The two items are a player and a bullet. The player is static in the X axis, but can jump in the Y axis, to avoid bullets flying at him, when the player taps the screen.

    When the actors collide, the bullet gets destroyed, the player actor loses one life, and when all his lives are gone, gets destroyed and the game ends (goes to menu).

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    No interpolate is a brute force override of the physics engine. You need to use a move to behavior which works within the physics engine. Make sure you check run to completion.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @pHghost @The_Gamesalad_Guru
    The platforms going down are interpolating . Basically I have this game and you know when you collide with something you know how your actor slows down and then after a period of seconds it goes back to it's original position if you don't die like Temple Run!
    You know when you trip over a root or something how the monsters get closer to you and after a couple of seconds if you don't die you end up losing the monsters and going back to your original position. That's exactly what I'm trying to in my game expect of tripping over roots and stuff you slow down when you collide with a wall. Get me? So I played around this for a little and I said: (aside the main actor does get pushed down because of the platforms interpolating)

    Rule:
    Collide with Platform
    Do
    Timer:
    After 3 seconds
    Interpolate self position Y to 160 for 3 seconds (That's the rule I put under the main actor and that's it's original position.)

    The thing is, is that when the player is interpolating to its original position platforms are still coming towards the main actor and instead of colliding with the platforms and restarting the whole rule over again, it goes right through them until it gets to the 160 position.

  • pHghostpHghost London, UKMember Posts: 2,342

    @The_Gamesalad_Guru‌ -- that really does depend on what you are trying to do. It overrides it for that object and for that specific movement. But if there are objects in the way, for them the physics engine is still active, so they will react to a collision with an interpolated item.

    If @http_gamesalad‌ explains what he is trying to achieve, there may be a way to solve the issue even with interpolating.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @pHghost I just explained what I wanted to do? Want me to make it clearer?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    :smiley:

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @pHghost said:
    The_Gamesalad_Guru‌ -- that really does depend on what you are trying to do. It overrides it for that object and for that specific movement. But if there are objects in the way, for them the physics engine is still active, so they will react to a collision with an interpolated item.

    If http_gamesalad‌ explains what he is trying to achieve, there may be a way to solve the issue even with interpolating.

    I understand that. I'm trying to keep it simple at the moment.

    @http_gamesalad‌ one trick to keeping a move to behavior going is to put it in an every zero timer. It's not pretty code but it is many times effective. Also you could stop the platform when it collides with the player momentarily so it doesn't trap the player and interfering with the move to.

  • pHghostpHghost London, UKMember Posts: 2,342

    @http_gamesalad‌ -- oh, your post for some reason didn't show up when I was posting! I'll have a look at it.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @The_Gamesalad_Guru thanks will try that and @pHghost thanks for taking time out to help me :)

  • pHghostpHghost London, UKMember Posts: 2,342

    @http_gamesalad‌ -- OK, I think I understand. And the player jumps over the platforms to avoid them?

  • pHghostpHghost London, UKMember Posts: 2,342
    edited August 2014

    @http_gamesalad‌ -- I'm attaching an example I quickly put together.

    You have a character (square) who can jump, and platforms coming at him. If he jumps over, he's fine. If he doesn't, at first he trips and slides back and if he trips again while he is back, he dies.

    Both the platforms and the character are moved by interpolating their Y position and all collision detection works. Have a look and compare it with your own logic to figure out what the issue is and how to fix it.

    If using the Move To behavior, make sure you selected relative to scene, not actor.

    P.S. (some more advanced babble):
    What does NOT work in GameSalad with Interpolate, is the Collide behavior. Collision detection in rules should work normally. When an actor is being interpolated, it does not react to "Bounce when colliding with:" and doesn't change its speed or direction. But that doesn't mean that collision has not been detected by GameSalad. If you have a Collide behavior in the other actor, IT will react to the collision accordingly. And what you can do then, is to change a global attribute saying that the collision took place, which can feed back into the interpolated actor.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @pHghost thank you for taking out your time! I'm not currently on my computer but ill check it tomorrow thanks again!

  • pHghostpHghost London, UKMember Posts: 2,342

    No problem!

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @pHghost I love that jumping behavior! :) I never thought about it. I'll need to figure how to incorporate it in my game so how! If I have any problems with the template mind if I inbox you? I really appreciate you taking out of your time to do this !

  • pHghostpHghost London, UKMember Posts: 2,342

    @http_gamesalad‌ -- ah, I somehow assumed you'd have jumping there. If you have a different way of avoiding the obstacles, stick with your vision!

    In any case, definitely inbox me if you have any problems with the template. Glad I could help!

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

    @http_gamesalad said:
    Is there anyway possible you can't make the interpolate and collide work together?

    I've not read the whole thread, so maybe someone's already posted this, but in case it's not been suggested . . . . you can interpolate an attribute, and constrain the actor to that attribute.

    So - for example - instead of interpolating an actor from x=0 to x=800, you would interpolate an attribute from 0 to 800 and constrain the actors x position to that attribute.

    This way you can interpolate an actor and have it recognise collisions.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    The best way is to manipulate linear velocity. It keeps collisions intact.

  • pHghostpHghost London, UKMember Posts: 2,342

    @Socks -- nice one.

  • http_gamesaladhttp_gamesalad Member Posts: 1,340
    edited August 2014

    @socks Okay ill try that thanks:)

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2014

    @http_gamesalad said:
    Socks how would you interpolate an attribute? lol

    Is this a trick question ? :)

    You would do it using the interpolate behaviour ?

    ?

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks yea I know I wasn't thinking when I commented that . lmao

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

    @http_gamesalad said:
    socks yea I know I wasn't thinking when I commented that . lmao

    :)

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    @socks Okay this is what I did I made a real game attribute and called it BackToPlace and set it to 0. Then In my Main actor I said

    Interpolate self position Y to BackToPlace for 3 seconds
    and I changed attribute BackToPlace to 160.
    Is this what you were talking about?

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2014

    @http_gamesalad said:
    socks Okay this is what I did I made a real game attribute and called it BackToPlace and set it to 0. Then In my Main actor I said

    Interpolate self position Y to BackToPlace for 3 seconds
    and I changed attribute BackToPlace to 160.
    Is this what you were talking about?

    No ! :D

    I was suggesting you interpolate an attribute, and constrain the actor to that attribute.

    In your example you are interpolating your actor - and not the attribute.

    . . . . . .

    Interpolate BackToPlace from one value to another.

    Constrain one of your main actor's attributes to BackToPlace.

Sign In or Register to comment.