[Solved] Want to have a platform shoot up by 100-200px when physics object contacts, then go back to original position

I’m making a physics platformer, and want to have an instance of a platform shoot up by 100-200px when physics object contacts, then go back to original position. I want to throw the physics object up to get to higher parts of the scene.

I’d the instance of the platform fall back to it’s original position and be able to be triggered again. I’ve tried using a force, but found it somewhat unpredictable. Tried using tweening, but can’t seem to get it to go back, be triggered more than once, nor throw with enough force.

Any suggestions?

So it will tween into the air? If that’s the case, then it’ll be a matter of storing the original position before the tween is set, and when the first tween has finished, remove it and create a second tween to return to the original position.

Also, you may want to add a force to the player as you start the first tween, instead of relying on the platform to provide thrust to the player.

Yes, it’s a side scroller and I want the platform to move up, and then back down to throw the object up higher.

If I add a force to the player, will it keep the angle the player was falling into account? I don’t want it to shoot strait up if the player was falling at an angle.

With the tweening, I am finding that sometimes the player hits the platform multiple times as the platform rises, which makes the platform keep rising the set amount each time. It’s a mess.

I have gone through so many different methods and none work quite right.

My first thought was to do an animation of a platform with a sort of “scissor lift” or spring underneath, but I couldn’t get that to work either.
Some things are starting to make sense in GD, but I’m still so new, so a lot of things are really difficult.

I tried to remove the tween, but maybe I did it wrong. It’s not working. Here’s a screen grab. It still has some elements of the timer and variables I tried using to fix it, but the activating parts of those are toggled off for now.

I would have thought it would keep any horizontal velocity when applying a vertical force.

Maybe you have done it the wrong way, but there’s nothing in the screen snip that indicates the removal of the tween.

Oops! I accidentally cropped out that part when saving the screen grab.

Here it is with the remove tween part.

Do I need to have more actions to tell it to bring back the tween, or is that automatic? In as far as having it trigger again, or trigger another instance. Right now when the player hits it, it goes down instead of up, then no other tween is triggered on that or any instance the rest of the game.

I just tried to do what I saw in the tweening example GD file. Here’s a pic of what they did:


Here is what I did. Though I couldn’t figure out a command for the line, “Repeat for each instance”. How do I trigger that?

This still won’t work. You’re only checking if the tween exists while MainChar and JumpStick are colliding. You need to move the two tween events (and their subevents) to the left by one level. And get rid of the creation of the MoveUp tween in the last vent, otherwise the platform move up and down continuously.


To get the Repeat block, right click on the “Add a new event” and select “For each Object” :

or click on this button on the top right in the events editor image and select the same option as above.

Thank you for the explanation. I think I did what you suggested, but it is still not working.
I wasn’t sure what you meant by the creation of the MoveUp tween in the last event.

Here is what I have now.

You don’t need a repeat for each jumpStick. It just adds processing time and overheads. The “JumpStick is colliding with MainChar” will filter the list of JumpSticks to just that one you’re after.

You don’t need the jumpStickVar. It’s preventing the actioning of subsequent jumpStick & MainChar collisions, because I can’t see where you reset it back to 0. Remove it, and replace it with a check that the object timer JumpStickDelay is greater than a particular value.

Here are the edits :

Thanks.

I think I did what you described. It lands on the jumpstick, and the jumpstick keeps moving up beyond the number of pixels I specified, and then it drops down out of the screen entirely.

Here’s what I have now.

You’ve inverted the timer condition. It reads as “The timer JumpStickTimer is less than 1 second”. Then you reset the timer to 0 (i.e. resets to a value less thatn 1 second). So it’ll fire the whole time MainChar and JumpStick are colliding (about 10-12 times while the tween moveUp is playing).

Undo that condition so it’s not inverted.

It’s still doing the same thing, inverted or not.

Is the JumpStick a dynamic or static body (it’s in the Physics settings). It should be static.

Originally I had it on kinematic because I thought if I moved it with a force or tween that’s what it needed to be.

Because of your suggestion just now, I changed it to static, but it’s still acting the same way.

To confirm, the problem is that the JumpStick is dropping below the position it originally started at?

Yes. All the way off the bottom of the screen.

Ok, this was an easy one to overlook - you’ve got a capital P in “moveUP” in the name of the first remove tween. But you’ve named the tween with a lower case p - “moveUp”. Names are case sensitive.

That did the trick! Thank you so much! The way my brain works, I don’t think I would have ever caught that. Though I will now add that to my list of things to look for when functions aren’t working correctly.

Just did a bunch of play testing. If I have a timer that gives a delay to the trigger to try and keep it from retriggering to quickly, it also seems to not trigger the jumpstick the first time it hits.

Is there a different way to have it react to collision right away, but then give .5 of a sec or so before being able to get triggered again?

Create/reset the timer on each JumpStick at the beginning of the scene. That will set it going and by the time you hit a JumpStick, the timer will be well over 1 second.