"Move to" Problem
http_gamesalad
Member Posts: 1,340
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
@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).
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@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.
@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.
@pHghost I just explained what I wanted to do? Want me to make it clearer?
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@http_gamesalad -- oh, your post for some reason didn't show up when I was posting! I'll have a look at it.
@The_Gamesalad_Guru thanks will try that and @pHghost thanks for taking time out to help me
@http_gamesalad -- OK, I think I understand. And the player jumps over the platforms to avoid them?
@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.
@pHghost thank you for taking out your time! I'm not currently on my computer but ill check it tomorrow thanks again!
No problem!
@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 !
@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!
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 best way is to manipulate linear velocity. It keeps collisions intact.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@Socks -- nice one.
@socks Okay ill try that thanks:)
Is this a trick question ?
You would do it using the interpolate behaviour ?
?
@socks yea I know I wasn't thinking when I commented that . lmao
@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 !
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.