How do I start an animation when the player is in the area?

0 favourites
  • 13 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi folks, I have a barrel which shoud fall into the scene from top once the player is in the area.

    Right now the barrel is falling as soon as the game starts so the player never sees the barrel.

    How can I achieve this please?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So the barrel is off screen(above the viewport)? You could compare the Player.X to Barrel.X, then when it equals the distance from the Player, you want it to fall. Then have an Event that causes it to fall.

    You could do this multiple ways. Have the Barrel simply drop/fall into the screen, by moving it's Y position over time. Or give the Barrel Object the Physics, or Platform Behavior. And, place it on top of an invisible solid platform out of view. Then once the Player is in range, have that invisible solid platform be destroyed. (Thus causing the Physics or Platform behavior on the Barrel cause it to begin falling).

    EDIT: If it was me, I would just adjust the Y position over time, and add in any other effects you like. Depending on if the barrel is landing on top of something, or just falling out of view.

    I hope that all made sense. There are always a bunch of different ways to achieve any type of effect. If you really get stuck, feel free to upload your project file somewhere, and I can take a look.

  • Thanks a lot. What u saying makes total sense. Since i'm just starting I will experiment thanks to your tips.

    How is the distance from the player calculated?

  • It would be something like this. Setup an Event for your player. Select "Compare X", then "Less or equal" to "Barrel.X + *Put your desired distance here*"

    EDIT: There are a bunch of different Events under the "Size & Position" area of your objects in the Event Sheets. These allow you to compare height, width, X, Y, on-screen etc.

    That said. You could have something "On-Screen" get checked, that causes the barrel to be dropped as well.

  • Awesome! Thanks a lot.

  • Ok sorry man, I'm a pain.

    Now I have the problem that the barrel falls but it self.

    I should in some way tell him to not move and wait for the action to be done. Can u help?

  • Ok sorry man, I'm a pain.

    Now I have the problem that the barrel falls but it self.

    I should in some way tell him to not move and wait for the action to be done. Can u help?

    Sure thing :). Happy to help some folks in the community out.

    We would need some more information to help out. I'll be online for about 30 minutes today. How do you have things setup? If it has platformer, or physics. You could have the behavior(whichever one is being used) disabled by default. There should be a checkbox on the left hand side with the object selected. Then in the Action of the player coming within the desired distance of the barrel, enable the platformer or physics behavior with an event.

    That is, if that is the route you went with this game mechanic.

  • Thanks man got it!

    I created an invisible sprite which triggers the barrel when the player walks over it.

    I unchecked the "enabled" check as u suggested. Than i created an event when if the player overlaps the invisible trigger sprite, than the physics of the barrel get enabled.

    Working great!

    Thanks.

    P.s.

    Now my problem is that id order to make collide the barrel with the surface, i have to set the surface as physics behaviour. Since it's already a Solid, it's not walkable but the player anymore, seems like the solid behaviour and the physics one are not good friends.

    Can u help?

  • Hey there, I would recommend to switch to Plateform behavior for the barrel, it will be easier to handle, Physics has its own collision system and doesn't mix well with the other behaviors, just be sure to disable default control in Plateform settings for the barrel, otherwise pressing left/right will make it move

  • Could He not do

    Object is on screen

    Trigger once

    Set animation 1

    Then invert it for when its not in The screen?

  • Sorry, yeah I should have mentioned that physics/platform behaviors cannot be both enabled.

    I still don't know how you are doing this? Sounds like the barrel supposed to land on something? If so I would set it to Platform object. Set platform to disabled to start.

    Then like Sami424 said, set it so, when on screen enable platform behavior(which will make it fall at the speed set in the Platform properties. If it lands on something, then that's fine.

    If it's falling off screen, then set the Platform behavior back to disabled, and reset it's position back to it's original X & Y coordinates, if you want the falling barrel to be a repeatable game mechanic.

    As Tomycase said, you should also disable the default platform controls as well, or else the barrel will move along with the player.

    Apologies for the confusion. It's really challenging to help troubleshoot various issues, without as much information as possible. For all of this to work at least small portion of the barrel would need to be within area that would then be shown on screen when the player reaches that point.

  • That indeed depends of the wanted result with the barrel behavior overall : must it be stopped when touching the floor? Will it go through? Will its position be reset after that?

    Providing as much details as possible is the best way for people to help you on your game, the more details we have, the better we can look for a solution for you ~

    Tho from what I understand so far, the barrel must hit the floor, in that case Plateform is the best behavior, however if you change your mind, Custom Movement would be perfect for that, as it allows you to move an object horizontally and verticaly, then handle any collisions through "code"

  • That indeed depends of the wanted result with the barrel behavior overall : must it be stopped when touching the floor? Will it go through? Will its position be reset after that?

    Providing as much details as possible is the best way for people to help you on your game, the more details we have, the better we can look for a solution for you ~

    Spot on. There are always many ways to achieve any result. The best option, depends on the intended result.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)