Ive been making a third person locomotion system and have a few questions.
Heres a video of my progress so far
My next step is to make an in air / jump system, which can be simple, but the way I want to go about doing it may be tricky. My final goal, is when jumping or entering an in air state, to calculate or trace the capsules trajectory, and then find the distance of the character to the landing spot. I want to do this, so I can always tell when the player is about to land. That way I could have a blend-space that blends from an in air pose to an about to land pose. I know I could just find the altitude or distance from the ground through a straight line trace downwards, but problems would occur when jumping over gaps (altitude would go from low, to high, then quickly back to low). If I could calculate the trajectory instead, I wouldnt have that problem.
If you have any suggestions, or know of a way to do that it would be a big help!
Maybe I could make this easier to understand. Basically I need to calculate a landing point based on the current capsule movement in air, and then get the distance from the capsule to the landing point.
Looks cool from the video. Did you make the model & animations?
If I’m understanding right, my approach would be to just recreate the gravity calculations and do a trace each step of the way. So loop through however far ahead in time you want (lets say 10 time steps worth) and move a temporary vector variable position (as if it was the capsule moving) at each step, checking if it touches anything. Then, when it touches something, just add up the delta time for each step (so lets say on the 6th iteration it hits something, and you’re checking in 0.05 sec intervals, the time until touchdown would be 0.3seconds). If you do this method, make sure you take into account the gravity setting, the gravity scale of the character, and make it framerate independent. A lot of explanations if you search for “framerate independent gravity”. If you’re struggling I could send a screenshot of a blueprint where I’m doing my own gravity calculations (on a bullet, but same principle applies).
However, that might get complex / messy if you’re needing the full capsules collision to be checked. The above method would probably only work decently for something point based. Maybe there’s some way you could loop through and simulate the movement on a separate / invisible copy of your character but I’m not sure. If there was some kind of capsule trace to use instead of a linetrace that’d achieve the same.
And ok…a bit more complex then I would have hoped…Pictures would be great! I really only need to trace from the bottom of the capsule, however a full capsule trace would be nice.
I think I got the math wrong on what I was going to screenshot so I made it from scratch with the default first person game. I spawn some spheres at each ‘step’ so you can see the predicted path too. Keep in mind this will be blocked by walls not just floors. There will be a few workarounds for that if it’s an issue.
Its a bit messy because I tried (and failed) to get it all visible in one screenshot. Instead, I made a video scrolling through the blueprint, hopefully you’ll be able to pause and see whats going on to copy it or make your own.
It turns out there is a capsule trace. I didn’t realise until after I did it this way. To do it that way it’d be the same process, except you’d need to input the capsule dimensions. What I’ve done here is created a “footbox” component at the base of the capsule and used that.
Edit: Obviously if you run this every tick (not just when you press a key) the time until impact will keep being updated. If anything messes with it (changes in gravity or other outside forces) the latest value will be the most accurate as it’ll keep correcting the time before impact.
Edit #2: You mentioned finding the distance in your original post, but I think the time is what you’re really after if you’re timing a land-preparation animation. But this could easily be a distance calculation after the loop if that’s what you need.
Are you planning to release the model/anim system on the marketplace? I’d be interested in buying it if so for a game I’m working on, looks quite solid, especially like the stationary turning thing.
The video looks like exactly what I need. Ill spend some time tonight to work on it.
As for putting it on the marketplace, I dont think its ready yet. I may use this system for a team project so I dont know if I can release it. I did show all of my blueprints though
Can you use this same method to predict say where a grenade would land before you through it? Or is there a way to curve a line trace based on a projectiles properties. Trying to make some way of letting the player know where a nade will land before he throughs it basically.
Yeah the same formula would apply to anything moving with a constant velocity (horizontal) and a linear acceleration (gravity). If the grenades are able to bounce and such, you’d need to build that in to the prediction which might be difficult if you’re using the physics system. But if you moved / bounced it using your own formula (ie, reflect vector by normal, moving the grenade manually in the same stepped way as the prediction) you’d be able to get it accurate.
The reason the bouncing would be difficult to predict if using the physics system is you’d need to re-create all of the calculations the engine uses for physics simulations. IE, the shape of the object(s), their rotation speed, etc.
For all I know, there might just be a physics simulation / preview / prediction ability already built in, but I haven’t come across it.
So the object has to be spawned and moving before you can use this formula? No way to do a prediction before you through the object? And have a decal spawn at point of impact of where it will be? So I want to hold button down, have the the prediction come up and update as I rotate character, then on release, through the object and have it land where predicted. Awesome if you could make a video of that. Appreciate the help
Exactly the same formula and method as the previous video. Just instead of setting the temporary variable to the CURRENT velocity, use the initial velocity of your grenade. So if you’re launching the grenade at 800 units a second just set that as the starting speed prior to the loop. As for spawning the decal it’d be better to create a blueprint containing the decal, and just set the actor location to the most recent predicted landing point. That way you’re not spawning / destroying 100 decals a second, just moving it.