How can it?
If you set the boolean to false as shown, the function to move or check direction would never be called at all.
The problem is probably that you have custom events instead of axis inputs.
How can it?
If you set the boolean to false as shown, the function to move or check direction would never be called at all.
The problem is probably that you have custom events instead of axis inputs.
So it’s possible I’m using the enhanced input component incorrectly?
I got it to work, albeit convolutedly.
It’s possible the initial set up for those was not done as a controller input.
You can add buttons to controller to map to axis values, but the underlying code in the engine is - or hey, at least it was, I haven’t looked at those in 2 years now - different when you start off with a button (it’s not axis).
It’s generally best to stick to the axis for movement - even if you are only implementing keyboard only. Because you don’t have to change stuff when eventually adding controller support (which is basically required now a days by distributors).
No problem, I’ll just stick to what I have now, since that’s what’s taking the axis for movement. Rotation’s working too.
Problem is just translating the character to the correct location now.
This is predicated on the collision capsule.
To align the character against the wall it’s probably easier to add a socket to spine_02 on the mesh.
Trace backwards.
Shift the skeletal mesh to the hit…
Also - Does the collision capsule really have to be that fat?
It should fit the body width (not shoulder to shoulder but fat butt to fat belly) so that you can do predictive animation stuff and turn him sideways to pass in tight spaces…
That’s a good idea, to be frank I learnt about arrows yesterday (despite me actually being a user for a longer time I haven’t started using UE until around now), so you’re probably right about just probably adding a socket and always tracing backwards so I’ll try and see if I can do that. The default capsule is defaultly horizontally fat but I’ll tweak around with that. Thanks for sticking it out so far.
If we do it this way, then would there be a need for the box trace? I’d assume so for the predictive movement.
Yes, the box trace is probably unavoidable.
The single line trace is cheap though.
Make sure to disable it with a conditional (bool).
And toggle the boolean back to on when the input key is pressed and you are in a wall cover state.
Keep in mind, if you shrink the box to fit between belly and butt you may not need the trace.
It then depends on the animation, as the animation can be ourside the capluse.
Thats really where predictive animation comes in…
Trace from:
The hands (palm down plam up),
The head (all 4 dir, plus up.),
spine, one backwards one forwards.
Pelvis, back, forward and down.
Knees, forward.
Heel, backwards down.
Toes, forward up/down.
Then you invent a way to adjust the animation so it doesnt clip situationally to the action.
Each trace is obviously toggled on/off and only used once when the action you want to fine-tune at runtime starts.
I see, so you can’t directly set a mesh’s rotation inside of the character class, from what I understand at least, so probably set actor rotation, but I’m curious though, how would you get the rotation from a line trace though?
I do find something odd though, so I was attempting to do a line trace with one of the red arrows, then place the actor at the arrow’s world location, however it doesn’t go to the arrow’s location but somewhere way off.
Made capsule way smaller now, it’s not exactly from the stomach to the back though so I might have to move around the capsule a bit…
Now that I think about it, using the arrows would probably not be the way to set the new location of the character.
Not quite.
You can toggle root motion and rotate the root bone to donit from inside an animation.
The rotation of the mesh however, is predicated to that of the root bone regadless, so you can rotate the root bone and achieve the same goal.
Basic trig.
Line trace impact normal, and actor backwards (not forwards, in fact, just use the socket if you don’t rotate the mesh) vectors are the 2 sides of a rectangle.
Calculate the acute angle…
I see, instead of constraining the character to the plane then, I could just have a line trace from the spine always pointing backwards and if it hits, it’s like attaching the player to the wall, in that case I think other types of walls and not just box ones would be possible, and because of the box trace, it wouldn’t be possible to go up for instance due to it always being false if it doesn’t hit something. Actually that’s not going to work in terms of diagonal movement with how I’ve set up my BP.
Tried with the trace impact normal already. Wait I shouldn’t be turning the Z, but the X.
Z of the character.
Not sure where X comes in.
But imho you need to play an animation to get into cover that rotates you via root motion.
What you do is you film/record/make an animation that goes the full 108deg.
You then remove the rotation out of the animation and take the Z value of that rotation into a curve.
You then play the animation from whwrere the angle tells you matched into the angle of the curve.
That way if you only need to twisr 75deg to align yourself, it literally does just that via animation…
And id also just use root motion to rotate the character with that.
Alright, will do that, thanks for the help so far, mate, seriously. Would it matter what direction the animation is turning from, left to right, right to left?
yes if you want the quickest path possible to the wall.
(you have to have 2 aims and you need to pick the right one based on the angle)
Regarding your other comment.
Don’t rely on the line trace being true or false to manage the state.
It’s quite possible it won’t be true in all situations that you actually are in cover during gameplay - plus, you really don’t want to run the test if you can avoid it.
a simple example of it being false but you being in cover would be when peeking corners
I’ve encountered this problem now, I think what I might do instead is allow the player to move diagonally, but the problem is constraining the player’s diagonal movement correctly, like you reach a corner, and the game recognises you can move around it.
Directionally speaking, from the perspective of the character, he would always be able to move diagonally left-down and right-down . Since the animation would handle the rotation, would that also be used to make sure that the player would always turn diagonally correctly?
But I’m assuming programming wise I’d have to make a check left-down and right-down somehow to make sure I’m actually hitting the wall if I’m moving diagonally, else don’t move in that direction.
Not sure - mostly because we are talking abstract.
In theory, if you handled the turn via animation - root animation, you are always covered.
If you haven’t the theory is simple.
Make an animation that goes left 180deg.
Make one that goes right.
Output the z rotation of the root bone into a curve.
Remove the actual root bone rotation from the animation.
Detect the start angle to use (actor rotation vs wall normal. Chances are its always 0).
Detect the end angle. Math based on Wherever the normal impact of the end position.
Play the animation until the curve reaches the calculated degree value.
Use the degree value of the curve to rotate the root bone (which should rotate the character in local space).
Transition to the move end. Move end is an animation that syncs current position to idle.
Done.
The statemachine setup would be.
Start transition > rotate idle > end transition.
Fairly simple/similar to turn in place setups.
If you feel the need to watch 8 hours of completely useless material on it, search for the live training which can be summarized in maybe 3 lines of text?
Ps:
I’d actually also output the root bone x/y/z and take a couple steps while animating the transition. Then passs the location to the root bonr on top of the rotation in the same way.
Its 3 more curves of data.
Probably just fudge with the blend time to transition without the feet screwing up.
I see, did you ever encounter bugs with the IK retargeting in UE5? I remember trying to retarget a few months ago and it was bugging out completely (tried Mixamo to UE5’s Manny). I managed to find a workaround with it but I’m curious since someone told me there’s bugs surrounding that system right now.
I dont use the latest, most projects are stuck in .25 before they broke the rendering pipeline.
Works fine there. But if therea a bug in the current distro I’d have no idea.
Been busy and haven’t been able to work on this, I’m back.
I also have the angle as well, I’m pretty sure FindLookAtRotation does the trick so I just did that instead of finding the dot product which should also give you the angle between two vectors
How exactly would this work, from what I understand with the anim curve functions, they’re all just getters so I can’t really plug my angle as the end value for an anim curve, unless I misunderstood what you were talking about.
This I can figure out, i.e. GetCurveValue then plugging that value in for setting the rotation. And yes, I suck at animation.
Another odd thing is I’ve set the animations to be root motion enabled, but it’s not considering that
Oh I think I see the issue, this is an animation sequence, currently my root motion mode in my animation blueprint only accepts root motion from montages. Yea if I set it to accept everything my cover movement animation breaks.
In an animation statemachine you can test the anim curve VS a hard value to enter/exit states.
In montages, you just play the next one at the right time - pulled from the anim curve.
The angle able is what you use to test the current state.
You can also use it to start an animation at a specific spot.
If the animation is set up for it, but thats far more complex.
If you built in c++ I may share some code that pulls the starting time by finding the curve values and returning an array. If you need to start at a specific frame thats pretty much the only right way to do it. Unfortunately, its a bit processing heavy.
It could be better to just copy/paste a curve into a curve asset and query the curve asset for the specific animations that require this behaviour.
Basically take the animation part out of the query portion…
If you built in c++ I may share some code that pulls the starting time by finding the curve values and returning an array. If you need to start at a specific frame thats pretty much the only right way to do it. Unfortunately, its a bit processing heavy.
I have not built it in C++, currently I’m just using blueprints to handle the animation for prototyping (and using the current character templates too), I do C++ but it’s for handling other functionality, but if you’re willing to share, I’d love to see it, it would also be good for documentation purposes as well if someone else were to ever stumble on this thread.
It could be better to just copy/paste a curve into a curve asset and query the curve asset for the specific animations that require this behaviour.
Oh I see, so I’ve been going about this the wrong way, I thought you were talking about anim curves, like taking those out somehow, again, if that’s the case, my bad for noobie mistake, I’m assuming then it would be passed through a timeline (via timeline animation)?