Character Movement Component Doesn't Update
I've been working on making a simple follower for my player character in a 2D platformer I'm making with paper sprites. I created the follower as a child of the Paper Character Class, gave it a CharacterMovement component, and set a timeline and vector lerp to get it to move from its current location to the location of my player character. Now I've moved on to trying to animate the follower, and I've noticed something strange happening with the CharacterMovement functions. They don't seem to update.
I use a function to change the flipbook that the follower uses depending on the value of a boolean called IsMoving. That boolean is determined by the function IsWalking from the CharacterMovement component. So if IsMoving is true, the follower should use its walking flipbook, and if it's false, it should use its sitting flipbook. However, when I test it, the follower doesn't stop walking, even when it's not moving anymore.
In the debug window, I've found that IsWalking actually stays true all the time - it doesn't update to false when the follower stops moving. The same thing happens when I use IsMovingOnGround. I've also tried using a separate method for seeing if the follower is moving - I use GetVelocity to see if it's moving, but that doesn't work either. Again, when debugging, that value is always at 0, regardless of whether or not the follower is moving. You can see the different attempts I've made in my blueprint below.
So how can I get around this? Is there something about using a timeline to move a character that messes with the CharacterMovement component/GetVelocity? Any help would be greatly appreciated.
asked Oct 12 '15 at 03:34 AM in Blueprint Scripting
I don't know if this is still relevant to you but I think I see the problem, mind you this is just after a cursory glance and after a few drinks. I notice that you aren't moving your component with "Add Movement Input" function. That function in particular you're going to want to use for all pawns that have a designated controller (which most should by default barring any "complex" or extra programming on your part to the contrary).
Add Movement Input takes a direction (specifically a vector type, which for all intents and purposes should be normalized, or not have a length greater than 1. There are prepackaged functions that should be able to accomplish that for you if you drag off from a vector and type "normalize"), a scalar value (basically how fast do you want this to move in the direction provided), and a boolean, "Force" (which forces the input even if it should be ignored). Optionally you can specify a target at the top of the node stack if you are affecting an "alien" pawn, or a pawn other than the one you are currently putting this node in.
If you need an example, this is a bit more complicated, but I have an excerpt from a somewhat basic following enemy. The only thing you'll notice that is not a part of your available functions is my macro DistanceBetweenTwoPoints which is a basic algebraic formula that, as you guessed it, calculates distance between two given 3D points (also works in 2D because math). One last caveat is that I changed my locked plane to a different axis. I think the default is "Y" so you'll need to leave that as a 0 so you don't go plane hopping.
answered Mar 12 '16 at 04:08 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here