Platform Behavior Stores Vector X & Y Movement Even After Becoming Disabled?

0 favourites
  • 7 posts
From the Asset Store
Who wants to be a Millionaire Clone. An educational coding source
  • Hey everyone :)

    As always, I'm constantly learning new things everyday while using Construct 3. This was a new one for me today. It's not an issue for which I'm looking for help, which is why I am posting this under "General Discussion". I'm just curious as to if this is the normal function of Construct 3.

    Earlier this afternoon, I was working on an Edge Grab mechanic for my Player's State Machine. Oosyrag, here in the community was helpful in sorting it out.

    They recommendeded that I use the "MoveTo" behavior rather than "Pin", or "Set position"(using the lerp parameter to smooth out movement, as I was trying to do). While disabling the Platform Behavior when entering the Edge Grab State. I had tried this yesterday with no success, but took care of the gameplay issue today.

    I was having some difficulty with the drop down from the Edge Grab State. Basically, when "S" or the "Down Arrow" key is pressed the Player should simply enter the Falling state and drop in a stationary line on the Y axis.

    In my Action for the Edge Grab drop down condition, I was Re-Enabling Collisions, the Platform Behavior, Setting Player's State Variable to "Falling", then setting a timer to prevent an immediate Edge Grab after leaving that State.

    When I was trying to work it out in this fashion, the Player Object was moving upwards in the direction it was previously jumping while entering it's Edge Grab State. Sometimes this would cause the Player Object to jump up on top of the platform, rather than dropping down. Depending on the speed and height of the jump it was in when the Edge Grab was initiated.

    To fix this. All I had to do was set the "Platform vector X", and "Platform vector Y" to "0". Along with the Disabling of Collisions, and Platform Behaviour, on the Player Object.(which I already had in the Edge Grab state initially) After that, the mechanic works perfectly as intended. So, it seems that Platform Behavior's "Vector X & Y" are both stored, even after the object with the behavior has stopped moving in either direction. Such as using the MoveTo to move it to a specified X and Y coordinate, and setting Platform to Disabled.

    Apologies if my explanation is confusing. I try to note down each detail with these things.

    Is this how it's intended to be? I had thought that after Disabling the Platform Behavior, and then having the Object move and stop(like I'm doing with MoveTo). That the Platform Behavior would sort of start fresh on the Behavior once it was re-enabled. Rather than continuing along the previous Vector X & Y values.

    I really need to spend a day studying JavaScript, along with Game Math. That's becoming increasingly apparent XD

    EDITS: Changed title, and some wording.

  • Hey there!

    So are you saying that in your project, re-enabling the object's Platform behaviour also restores its previous vector x/y?

    With these kinda things, it can be helpful to make a project from scratch, with just the minimum objects you need to isolate your problem. A single sprite with Platform behaviour, a key to enable/disable that behaviour, and a text object displaying its Platform vector x/y should show you the answer.

    Or, if you're asking if that's a bug, the same minimal project will help folks here assess that.

    In either case, these quick focused tests are great exercises to find out whether its the behaviour's intention or something else in your code that's causing the output.

    Hope that helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey brushfe, and thank you for your response :)

    Yeah, that's exactly right. So if I was jumping up and to the right, then entered the Edge Grab State. Then, pressed down to enter the Falling State, it would jump up and to the right before dropping.

    Same goes for the other way around. So up and to the left. Setting the Vector X & Y to 0, helped the falling into Edge Grab State as well. For days, I was confused as to why sometimes the Player Object would fall at it's normal speed, and other times would fall much faster. It was because I was falling downwards into the Edge Grab trigger object. Then when pressing S or Down, it was adding the previous Vector Y to the Falling Speed.

    I was just wondering if this is normally the case. It's working perfectly now, that was just a couple extra Events that I needed to add to solve the issue. I just thought it was strange.

    I definitely appreciate your recommendation of creating a very basic, "Playground" if you will, with only the basic elements in the Project. I actually have one on my Google Drive called test.c3p filled with all different layouts, and groups of blocks on the Event Sheet. I add to it, to work out new gameplay mechanics, and only enable the Group in the Event Sheet that is required to test that specific gameplay element.

    I should have jumped on there, and tried to recreate the issue earlier today. I was just setting my player next to the Edge Grab trigger, and loading with each change on the Event Sheet. I'll definitely keep that in mind next time something strange I don't expect happens. To rule out anything strange that might be going on with my Actions/Events.

    Thanks for being super helpful :)

    EDIT: I will definitely keep in mind, adding more debug texts to my layouts as well. I currently have one over the Player Object for it's current State. Not sure why I didn't add one for the current Vectors. Must be one of those days, after little sleep, and out of sorts.

    EDIT 2: Just added text for the Player's current Vector X, and Vector Y to the project. Then, disabled those two Events that sets them both to a value of 0. And, there it was. The issue could have been right in front of me earlier... I feel dumb.

    Thanks again!

  • Haha that 'feeling dumb' is the best! I'm a card-carrying member of that club... I tell myself it means we're learning :)

    The playground experiments are a good habit! It's a good way to get a handle on a behaviour, and really helpful if you do in fact catch a bug and need to report it.

    I'm looking forward to your project - keep at it!

  • Hey there, that's how most of the behaviors working with vectors work in C2 and C3, it can be used in useful ways as well, for example, you can prepare your Vector X and Y values early and then enable the behavior when needed, it will apply immediately the previously set values

  • Haha that 'feeling dumb' is the best! I'm a card-carrying member of that club... I tell myself it means we're learning :)

    The playground experiments are a good habit! It's a good way to get a handle on a behaviour, and really helpful if you do in fact catch a bug and need to report it.

    I'm looking forward to your project - keep at it!

    Thanks so much! I feel the same way :). I had to rest my eyes for a bit earlier today, for a breather. While resting, I reminded myself that I am still learning, and each day is still progression no matter how much I get done. The finish line is never reached, only moved forward more and more.

    I tend to pack more on my to-do list than I can ever get done each day. But, whatever I get done, produces more knowledge I can store and recall for later use. Nothing like a good challenge!

    Like they say, we learn the most from failures. It's only a failure if you haven't learned from it, and progressed forward. Edison is quoted as saying something along the lines of, "We Now Know 1,000 Ways Not To Invent A Light Bulb". Without those 1,000 failures we would be without light.

    Best of luck on all of your projects, and endeavors as well! It's always nice to find a kind soul in communities like this one :). I hope you have a great day/night, whatever time of day it may be in your area.

  • Hey there, that's how most of the behaviors working with vectors work in C2 and C3, it can be used in useful ways as well, for example, you can prepare your Vector X and Y values early and then enable the behavior when needed, it will apply immediately the previously set values

    Excellent to know! Thank you so much for your input :). Now you've got my gears turning, for other projects and gameplay mechanics. I'll be dreaming about Vector X and Y tonight XD

    EDIT: Right now, imagining a grappling hook that grabs a point then launches the player up in the air like a rubber band.

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