create account

SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS by abmakko

View this thread on: hive.blogpeakd.comecency.com
· @abmakko · (edited)
$15.60
SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS
![boy_scene_banner.jpg](https://images.ecency.com/DQmWmiUarmvzxxGoFcu1BgrmbyDaWiRmY6vVBb7ZfzCn8Ub/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](https://images.ecency.com/DQmYDBLmhKvQMWiTjJC9FxCsXn7guCe7CthQL5vk1wmLp1m/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](https://images.ecency.com/DQmUWe3dbe3iu16vvYK2hoCZwJQZu1Pdhwqo9FWfpe5LLqh/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](https://images.ecency.com/DQmcwoyenPd1T25Eztkjxtt3v8p5ZGRKA6nZkUSBuzyhbBC/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.

<h4>SMOOTHING THE ANIMATIONS</h4>

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](https://images.ecency.com/DQmc41ukXvn74Au1Z7GJiz1FZGHPUYjsGnjbJkKmAPqCXrG/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](https://images.ecency.com/DQmY96BDtpywUeLyD9kz8Yq2QMRevsT3itj84dENijCBxQa/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](https://images.ecency.com/DQmeKyj6CjPQBEBJZJRXmsLEdKiWvkYrj6cAXUf2ZPuncq3/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](https://images.ecency.com/DQmSP7Q9hUGcyLMfJUPUQKHRytmScjVmADTjbeSR1YZLmxp/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](https://images.ecency.com/DQmbb4a4kb384JRgBvzNT8FBKDBwAZXwnNd53FL5CAUgfsy/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](https://images.ecency.com/DQmeZAXFSKL3Vv6vV4Bk89zjjo7k8MccSRHJDzxS7htnLsZ/st_8.gif)

<h3>WHAT NEXT</h3>

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](https://hive.blog/hive-176981/@abmakko/scripting-the-vector-motions-and)

<CENTER>![hive_banner_2.gif](https://images.ecency.com/DQmc4mzQXNGfYQi9HU9PTSR1tbcUMnbgqgK4QWvmmogkFis/hive_banner_2.gif)</CENTER>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 343 others
properties (23)
authorabmakko
permlinkscripting-artificial-gravity-and-smoothing
categoryhive-176981
json_metadata{"links":["https://hive.blog/hive-176981/@abmakko/scripting-the-vector-motions-and"],"image":["https://images.ecency.com/DQmWmiUarmvzxxGoFcu1BgrmbyDaWiRmY6vVBb7ZfzCn8Ub/boy_scene_banner.jpg","https://images.ecency.com/DQmYDBLmhKvQMWiTjJC9FxCsXn7guCe7CthQL5vk1wmLp1m/st1.gif","https://images.ecency.com/DQmUWe3dbe3iu16vvYK2hoCZwJQZu1Pdhwqo9FWfpe5LLqh/st_5.jpg","https://images.ecency.com/DQmcwoyenPd1T25Eztkjxtt3v8p5ZGRKA6nZkUSBuzyhbBC/st_2.jpg","https://images.ecency.com/DQmc41ukXvn74Au1Z7GJiz1FZGHPUYjsGnjbJkKmAPqCXrG/lane_movements.gif","https://images.ecency.com/DQmY96BDtpywUeLyD9kz8Yq2QMRevsT3itj84dENijCBxQa/st2.gif","https://images.ecency.com/DQmeKyj6CjPQBEBJZJRXmsLEdKiWvkYrj6cAXUf2ZPuncq3/st_6b.jpg","https://images.ecency.com/DQmSP7Q9hUGcyLMfJUPUQKHRytmScjVmADTjbeSR1YZLmxp/st_7.gif","https://images.ecency.com/DQmbb4a4kb384JRgBvzNT8FBKDBwAZXwnNd53FL5CAUgfsy/st_4.jpg"],"thumbnails":["https://images.ecency.com/DQmWmiUarmvzxxGoFcu1BgrmbyDaWiRmY6vVBb7ZfzCn8Ub/boy_scene_banner.jpg","https://images.ecency.com/DQmYDBLmhKvQMWiTjJC9FxCsXn7guCe7CthQL5vk1wmLp1m/st1.gif","https://images.ecency.com/DQmUWe3dbe3iu16vvYK2hoCZwJQZu1Pdhwqo9FWfpe5LLqh/st_5.jpg","https://images.ecency.com/DQmcwoyenPd1T25Eztkjxtt3v8p5ZGRKA6nZkUSBuzyhbBC/st_2.jpg","https://images.ecency.com/DQmc41ukXvn74Au1Z7GJiz1FZGHPUYjsGnjbJkKmAPqCXrG/lane_movements.gif","https://images.ecency.com/DQmY96BDtpywUeLyD9kz8Yq2QMRevsT3itj84dENijCBxQa/st2.gif","https://images.ecency.com/DQmeKyj6CjPQBEBJZJRXmsLEdKiWvkYrj6cAXUf2ZPuncq3/st_6b.jpg","https://images.ecency.com/DQmSP7Q9hUGcyLMfJUPUQKHRytmScjVmADTjbeSR1YZLmxp/st_7.gif","https://images.ecency.com/DQmbb4a4kb384JRgBvzNT8FBKDBwAZXwnNd53FL5CAUgfsy/st_4.jpg","https://images.ecency.com/DQmeZAXFSKL3Vv6vV4Bk89zjjo7k8MccSRHJDzxS7htnLsZ/st_8.gif","https://images.ecency.com/DQmc4mzQXNGfYQi9HU9PTSR1tbcUMnbgqgK4QWvmmogkFis/hive_banner_2.gif"],"tags":["hive-176981","neoxian","curangel","qurator","stemsocial","thealliance","ocd","hive-naija","creativecoin","indiaunited"],"app":"ecency/3.0.20-vision","format":"markdown+html"}
created2022-01-16 18:19:21
last_update2022-01-16 18:51:45
depth0
children7
last_payout2022-01-23 18:19:21
cashout_time1969-12-31 23:59:59
total_payout_value7.892 HBD
curator_payout_value7.709 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,842
author_reputation16,653,619,949,576
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,545,157
net_rshares13,202,136,377,683
author_curate_reward""
vote details (407)
@dante31 ·
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 
👍  
properties (23)
authordante31
permlinkre-abmakko-r5yceb
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.12.1"}
created2022-01-19 10:13:27
last_update2022-01-19 10:13:27
depth1
children1
last_payout2022-01-26 10:13:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length148
author_reputation68,599,805,208,174
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,640,956
net_rshares4,400,485,649
author_curate_reward""
vote details (1)
@abmakko ·
Thanks a lot... I appreciate the encouragement 🙏
properties (22)
authorabmakko
permlinkre-dante31-2022119t134526220z
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"ecency/3.0.20-vision","format":"markdown+html"}
created2022-01-19 11:45:27
last_update2022-01-19 11:45:27
depth2
children0
last_payout2022-01-26 11:45:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length48
author_reputation16,653,619,949,576
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,644,154
net_rshares0
@indiaunited ·
Indiaunited Curation 1642437984968
This post has been manually curated by @bhattg from Indiaunited community. Join us on our [Discord Server](https://discord.gg/bGmS2tE). 

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](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=184721.10239060794%20VESTS), [250HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=461802.7559765198%20VESTS), [500HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=923605.5119530396%20VESTS), [1000HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=1847211.0239060791%20VESTS). 

Read our latest [announcement post](https://hive.blog/hive-186042/@indiaunited/indiaunited-2-0-active-again-with-a-lot-more-energy-this-time) to get more information. 

[![image.png](https://files.peakd.com/file/peakd-hive/bala41288/46eaz12N-image.png)](https://discord.gg/bGmS2tE) 

<sub>**Please contribute to the community by upvoting this comment and posts made by @indiaunited.**</sub>
properties (22)
authorindiaunited
permlinkindiaunited-1642437984968
categoryhive-176981
json_metadata{"app":"hiveblog/0.1","tags":["hive-176981","neoxian","curangel","qurator","stemsocial","thealliance","ocd","hive-naija","creativecoin","indiaunited"]}
created2022-01-17 16:46:24
last_update2022-01-17 16:46:24
depth1
children0
last_payout2022-01-24 16:46:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,252
author_reputation61,792,591,185,374
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,576,297
net_rshares0
@verbalshadow ·
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.
👍  
properties (23)
authorverbalshadow
permlinkre-abmakko-r5u99h
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.12.1"}
created2022-01-17 05:15:18
last_update2022-01-17 05:15:18
depth1
children1
last_payout2022-01-24 05:15:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length220
author_reputation21,999,581,189,541
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,561,812
net_rshares4,373,112,441
author_curate_reward""
vote details (1)
@abmakko ·
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.
properties (22)
authorabmakko
permlinkre-verbalshadow-2022117t16657550z
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"ecency/3.0.20-vision","format":"markdown+html"}
created2022-01-17 14:06:57
last_update2022-01-17 14:06:57
depth2
children0
last_payout2022-01-24 14:06:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length433
author_reputation16,653,619,949,576
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,572,418
net_rshares0
@vikvitnik ·
*This is very advanced for me. Excellent job!* :p
👍  
properties (23)
authorvikvitnik
permlinkr5tfvx
categoryhive-176981
json_metadata{"app":"hiveblog/0.1"}
created2022-01-16 18:40:45
last_update2022-01-16 18:40:45
depth1
children1
last_payout2022-01-23 18:40:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length49
author_reputation126,416,641,051,365
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,545,642
net_rshares4,264,152,172
author_curate_reward""
vote details (1)
@abmakko · (edited)
haha Thanks @vikvitnik 🙂
properties (22)
authorabmakko
permlinkr5tg0d
categoryhive-176981
json_metadata{"users":["vikvitnik"],"app":"hiveblog/0.1"}
created2022-01-16 18:43:27
last_update2022-01-16 18:44:12
depth2
children0
last_payout2022-01-23 18:43:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length24
author_reputation16,653,619,949,576
root_title"SCRIPTING ARTIFICIAL GRAVITY AND SMOOTHING THE ANIMATIONS"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id109,545,707
net_rshares0