SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS

avatar
(Edited)

boy_scene_banner.jpg

I'm finally approaching the challenging aspects of scripting the physics and animations of this character. The important aspect was first defining the gravity variable and plugging it into the Vector3 components.

It took me quite a while to figure out the right approach.

st1.gif

As you can see, the character turned superman for a bit hehe...

I tried to use the (controller.grounded) method as I did in my previous attempt at this project but for some reason, the physics system was unreliable during testing. After a bit of research, I discovered that I need to create an artificial gravity system, so I solved this floating issue by using the Ray constructor.

st_5.jpg

Basically, as the name implies, it's like a ray of laser pointing at the ground, testing if the character is grounded or not, with that metric I can easily adjust and test the gravity variable until I get it right.

st_2.jpg

The ray lines is very visible in debug mode, It leaves a trail which also helps me gauge the jump height from an objective angle.

SMOOTHING THE ANIMATIONS

Now that I solve the gravity issue, I had to to move on to the animation issue, I discussed about lane movement issue in the last episode.

lane_movements.gif

As you can see above... the lane changing looks like it was gliding across, I figured a solution would be to implement a buffer animation when switching lanes, I needed something to interrupt his running stride.

st2.gif

Now with the buffer animation in between the lane changes, It looks a bit more dynamic and less laggy.

I also had to incorporate other animations into the character (jump, left, right) My animation window is starting to look crowded.

st_6b.jpg

I had a bit of issue with the jump animation, It kept leaving the root character position and zooming back in like a boomerang.

st_7.gif

I figured that the problem was from the mixamo fbx import, I solved it by tweaking the animation keyframes within Unity.

st_4.jpg

I just edited all the position z-axis properties of the animation, I override all the position.z values to zero in all the keyframes so that it doesn't leave the root position. Now the animation stays in place with the character.

st_8.gif

WHAT NEXT

I can't wait to get to the more fun part of 3d asset building and the sky box, I've figured out a dope idea for the sky box that I can't wait to try out, also I need to build another street tile. I would need a total of 10 street tiles in total, then I would spawn them at random as the game character progresses.

That is all for now, Join me next time as I tackle this issues... thanks for your time :)

Check out my previous episode here:

SCRIPTING THE VECTOR MOTIONS AND LANE MOVEMENTS

hive_banner_2.gif



0
0
0.000
7 comments
avatar

Strong improvements since the last post. Builtin physics for a lot of game engines have quirks and bugs. Glad you were am to fix this. The jump look more like a heel click to me, but maybe that is just the low res video.

0
0
0.000
avatar

yes indeed... thanks a lot for the feedback. there are two different types of jump sequences which I used. one is for switching lanes while the other is for jumping over obstacles, I believe it looks awkward now due to fact that I've not yet modeled obstacles into the environment and maybe cause of the compressed gif.

Although I will take your observations into consideration and continue working on defining a smoother animation.

0
0
0.000
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share 100 % of the curation rewards with the delegators.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

Read our latest announcement post to get more information.

image.png

Please contribute to the community by upvoting this comment and posts made by @indiaunited.

0
0
0.000
avatar

The lane movement looks good. I can't say much since I'm no game developer or expert but I see promise in what you're developing. Keep working hard

0
0
0.000
avatar

Thanks a lot... I appreciate the encouragement 🙏

0
0
0.000