Making A Physics Based Character Controller In Unity (for Very Very Valet)

  Рет қаралды 100,054

Toyful Games

Toyful Games

Күн бұрын

A detailed look at how we built our physics-based character controller in Unity for our game Very Very Valet - available for Nintendo Switch, PS5, and Steam
BUY NOW!! toyful.games/vvv-buy
~ More from Toyful Games ~
* Animation Deep Dive mentioned in the video - toyful.games/blog/character-a...
* Custom Car Physics in Unity: • Making Custom Car Phys...
* The Toyful Blog with even more developer deep dives - toyful.games/blog
* Purchase physical or digital - toyful.games/vvv-buy
* Download the FREE demo today - toyful.games/vvv-di
Video sections:
0:00 Intro
0:20 Part 1 - Capsule Theory
1:55 Part 2 - How to Float
3:25 Part 3 - The Run Around
6:12 Part 4 - Jump to It
6:48 Outro
#VeryVeryValet #NintendoSwitch #MadeWithUnity #GameDev #IndieDev #tutorial #tutorials #howto #PS5 #steam #epicgamesstore #Windows #Mac #PC #CouchCoop #Multiplayer

Пікірлер: 318
@mixandjam
@mixandjam 2 жыл бұрын
This video is perfect! Thank you so much for sharing the knowledge!! Love it, super well explained and fun to watch!!
@kerduslegend2644
@kerduslegend2644 11 күн бұрын
man, this is such a hidden gem. i dont know why i dont know your channel earlier
@joshuastubblefield2559
@joshuastubblefield2559 8 ай бұрын
Thanks a lot for this video. It's great! Here's my version of vertical hovering after following along. I researched a bit on spring-damp mechanics and was able to define the behavior using frequency and a damp factor rather than spring strength and damp strength. This way, you set dampFactor to 1 and it will reach equilibrium without over shooting. Set dampFactor to 0 to get a spring that (ideally) never loses energy. dampFrequency defines how fast it reacts. using UnityEngine; public class Hover : MonoBehaviour { public float dampFactor = 1; public float dampFrequency = 15; public float hoverHeight = 1.5f; public float maxDistance = 2; public float castRadius = .5f; public Rigidbody rb; RaycastHit[] hits = new RaycastHit[10]; private void Awake() { if (!rb) { Debug.LogError($"[{nameof(Hover)}] missing field RigidBody."); enabled = false; } } private void FixedUpdate() { ApplyHoverForce(); } void ApplyHoverForce() { if (GroundCast(out RaycastHit hit)) { Vector3 rayDirection = Vector3.down; float springDelta = GetSpringDelta(hit); float springStrength = SpringStrength(rb.mass, dampFrequency); float dampStrength = DampStrength(dampFactor, rb.mass, dampFrequency); float springSpeed = GetRelativeSpeedAlongDirection(rb, hit.rigidbody, rayDirection); Vector3 springForce = GetSpringForce( springDelta, springSpeed, springStrength, dampStrength, rayDirection); springForce -= Physics.gravity; rb.AddForce(springForce); if (hit.rigidbody) hit.rigidbody.AddForceAtPosition(-springForce, hit.point); } } bool GroundCast(out RaycastHit hit) { int hitCount = Physics.SphereCastNonAlloc( transform.position, castRadius, -transform.up, hits, maxDistance); if (hitCount > 0) { for (int i = 0; i < hitCount; i++) { RaycastHit current = hits[i]; if (current.rigidbody == rb) continue; hit = current; return true; } } hit = default; return false; } float GetSpringDelta(RaycastHit hit) { return hit.distance - (hoverHeight - castRadius); } static float GetRelativeSpeedAlongDirection( Rigidbody targetBody, Rigidbody frameBody, Vector3 direction) { Vector3 velocity = targetBody.velocity; Vector3 hitBodyVelocity = frameBody ? frameBody.velocity : default; float rayDirectionSpeed = Vector3.Dot(direction, velocity); float hitBodyRayDirectionSpeed = Vector3.Dot(direction, hitBodyVelocity); return rayDirectionSpeed - hitBodyRayDirectionSpeed; } static float SpringStrength(float mass, float frequency) { return frequency * frequency * mass; } static float DampStrength(float dampFactor, float mass, float frequency) { float criticalDampStrength = 2 * mass * frequency; return dampFactor * criticalDampStrength; } static Vector3 GetSpringForce( float springDelta, float springSpeed, float springStrength, float dampStrength, Vector3 direction) { float tension = springDelta * springStrength; float damp = springSpeed * dampStrength; float forceMagnitude = tension - damp; Vector3 force = direction * forceMagnitude; return force; } }
@sophies_games
@sophies_games Жыл бұрын
Just wanted to say this is the best character controller tut that I've seen, and all the character controllers I've made since watching this have been based off of this.
@MythicLegionDev
@MythicLegionDev 2 жыл бұрын
Awesome explanation and solutions, thank you for sharing! I've been developing a similar physics based character controller by trying to combine my favorite parts of a responsive platformer controller and a raycast vehicle controller so this is all super helpful!
@unexpectedme9992
@unexpectedme9992 2 жыл бұрын
Upload now bro
@simpathey
@simpathey 3 жыл бұрын
This is so exciting! I am pumped for the game, and thanks for talking in depth about your physics based movement and even showing code. I will for sure give this a go in my next game!
@yaderkunsama9454
@yaderkunsama9454 Жыл бұрын
I've been looking for an explanation, a hint on physics based movement for the past 3 months. This has really helped figure out how to do it, at least gave me a starting point. Thanks for the explanation!
@sutoreikyatto
@sutoreikyatto Жыл бұрын
I feel so lucky that this video exists since I've been struggling on implementing a physics based first person controller and this tutorial explains almost all the issues I've faced. Thank you so much!!
@Foxyzier
@Foxyzier Жыл бұрын
Can't stress enough how grateful I am for this video, there really isn't enough explanations on physics based character controllers like that.
@gabrielplourde6791
@gabrielplourde6791 3 жыл бұрын
This was very intelligently designed and explained. So many subtle changes that really bring it all together to near perfection, I love it
@TrentSterling
@TrentSterling 3 жыл бұрын
Great visualizations! Looking forward to implementing something similar!
@monochroma3803
@monochroma3803 2 жыл бұрын
i like how technical explanations are and art style is so cheerful and fun to watch ! good job !
@tdif3197
@tdif3197 Жыл бұрын
You guys have a great set of tutorials here. Glad to find another floating capsule user, it really is the way to go.
@geminiseDigitalTwin
@geminiseDigitalTwin Жыл бұрын
The hovering capsule mechanic is really clever. Finally found something that works for my project. Thanks for sharing. Amazing video. Great Explanation !!!
@groovykush
@groovykush Жыл бұрын
The most structured and detailed tutorial i ca across until now. Thank you very much!
@bignono5423
@bignono5423 Жыл бұрын
I have never thought of using floating capsules... this is so ingenius! I can't believe my solution to rough player controls was this simple. You are amazing sir!
@rohanvishayal8724
@rohanvishayal8724 2 жыл бұрын
Amazing overview and good explanation, thank you looking forward to playing the game.
@alicem3415
@alicem3415 2 жыл бұрын
Thank you. I was having trouble figuring out how to make my Rigidbody controller more responsive. This has made it much better.
@Leonardorth.
@Leonardorth. 3 жыл бұрын
This is exactly what I've been looking for. Thanks for sharing !
@ali32bit42
@ali32bit42 Жыл бұрын
i was so lucky this studio exists cause i keep coming back to this as refrence for my own game.
@CosmicComputer
@CosmicComputer 2 жыл бұрын
Oh my glob, this is freaking incredible, thank you for sharing this!!!!
@mg1632
@mg1632 2 жыл бұрын
Very neat take on a CharacterController! Thank you for sharing - subscribed!
@FlipYourLearning
@FlipYourLearning 2 жыл бұрын
Nice video. The code is well written and although I had seen this approach in other tutorials none could explain it as well as you did.
@ianainoaduarte
@ianainoaduarte 2 жыл бұрын
Great video, great explanations. Saved me a whole lot of headache, but I'm still having problems with the whole applying torque part.
@matejzajacik8496
@matejzajacik8496 Жыл бұрын
Wow, this is excellent! Straight to the point and very informative.
@budhechiranjiv
@budhechiranjiv 3 жыл бұрын
Nice, Good luck with your release!
@megasoniczxx
@megasoniczxx 2 жыл бұрын
I still don't get completely all of it but this has definitely helped me get a firmer grasp on what makes a good 3D character controller. Really insightful video.
@alazuli2291
@alazuli2291 Жыл бұрын
I just tried this method and it really works perfectly for me. Thank you.
@bubski3821
@bubski3821 Ай бұрын
this is one of the smartest custom controllers I've ever seen, so impressed with yall's work on this
@milankiele2304
@milankiele2304 2 жыл бұрын
I fought so hard to get the best character controller... Your knowledge is the path to fulfillment
@abentertainment786
@abentertainment786 Жыл бұрын
Thank you so much for all these tutorials bro. So much valuable knowledge
@CQIsMe
@CQIsMe 3 жыл бұрын
This is very cool! Ironic that I found this because I've been building a similar physics based controller but for the opposite. Realistic physics based movement XD Best of luck on your game!
@seanisthedude
@seanisthedude Жыл бұрын
Genuinely a fantastic and informative video. I ended up using some of the methods shown in my own game! I'm absolutely going to buy this game as a thanks (and also because the game looks great :P)
@outdoor1918
@outdoor1918 Жыл бұрын
This was just awesome! Thanks a lot!
@tophitgames7752
@tophitgames7752 2 жыл бұрын
Very well made video.. thanks for sharing this knowledge
@tapashsharma6542
@tapashsharma6542 Жыл бұрын
You are doing a wonderful job by giving Knowledge many thanks
@Usualyman
@Usualyman 2 жыл бұрын
This is epic! Floating character controller is pretty original decision! Never seen this before) Thanx!
@Ziboo30
@Ziboo30 3 жыл бұрын
This is gold ! thanks for sharing
@CamoflaugeDinosaue
@CamoflaugeDinosaue 2 жыл бұрын
Thanks so much for sharing, this is a very interesting approach! Would reeeeeally love to see your vehicle configuration! It looks like you're using Unity's vehicle/wheel physics, but it's more responsive and snappy than any controller using those Ive ever seen
@margaritamoreno2076
@margaritamoreno2076 Жыл бұрын
Tysm, did everything as described
@sabinudas5395
@sabinudas5395 Жыл бұрын
congratulations fam!!!
@spikebor
@spikebor 2 жыл бұрын
a very great system and carefully explained, thanks !
@Fghjkjhljhghj
@Fghjkjhljhghj Жыл бұрын
This was a great tutorial, thanks a lot!
@AlexBlackfrost
@AlexBlackfrost 2 жыл бұрын
Wow, great video! Thanks for sharing!
@theDarkerSan
@theDarkerSan Жыл бұрын
I combined this with ground normals movement (ground raycast hit normals plane projection ) and it turned out amazing! thanks again.
@mattsYT42
@mattsYT42 Жыл бұрын
could you please explain that in lamen's terms 😅
@fiflax2188
@fiflax2188 Жыл бұрын
Sounds perfect!!!
@ajajjssjdjdndns1917
@ajajjssjdjdndns1917 Жыл бұрын
Oh my god so good explained thank you!!!!
@gunzalkar
@gunzalkar 3 жыл бұрын
Great stuff very much helpful, Thanks!
@selfmades4494
@selfmades4494 Жыл бұрын
So informative, thanks a lot!
@ElSonk
@ElSonk 2 жыл бұрын
Super excellent! Thanks a million
@Malacord
@Malacord Жыл бұрын
BROTHER, YOU ARE THE BEST!!! You oooh really helped me!! THANK YOU VERY MUCH!This is cool, well done!
@Loys-vo7cz
@Loys-vo7cz Жыл бұрын
OMG, it really worked. Thank you so much!!
@apukumarsarkar7016
@apukumarsarkar7016 Жыл бұрын
Thanks for the tutorial
@benmendez7756
@benmendez7756 Жыл бұрын
thank you straight to the point
@torryjaja
@torryjaja 3 ай бұрын
This is absolutely fantastic
@cookiefells_ofc
@cookiefells_ofc Жыл бұрын
Beautiful man, you're the only one who helped me
@yarikhom905
@yarikhom905 Жыл бұрын
Thank you so much for sharing your experience with us. God bless you .
@denji6763
@denji6763 Жыл бұрын
you explained. Thank you so much.
@ian_snyder
@ian_snyder 2 жыл бұрын
This is amazing, sharing with my students :)
@user-dq2ul4bu2v
@user-dq2ul4bu2v Жыл бұрын
This method works perfectly .. thanks for sharing ;)
@hebashamaa7695
@hebashamaa7695 Жыл бұрын
Very helpful, thank you
@petrussian8228
@petrussian8228 Жыл бұрын
Thank you so much it was very helpful
@camilatontis
@camilatontis Жыл бұрын
Cheers man!
@pintadenis5641
@pintadenis5641 Жыл бұрын
That Guy Thanks, I will look into it later.
@OverInfrared
@OverInfrared Жыл бұрын
Making this work for VR was a bit weird, but worth it. Thank you.
@gonderage
@gonderage 2 жыл бұрын
really not gonna lie, im gonna use this method of applying torque to remain upright. It's super fun to mess around with the spring strength and damper values to get wacky reactions! I can get some really wobbly bois that way. Thank you so much for the video!
@geri4367
@geri4367 3 жыл бұрын
Awesome, thanks for sharing :D
@Zo.ro0
@Zo.ro0 Жыл бұрын
Thanks man! You nice tuto!!
@supercables251
@supercables251 2 ай бұрын
+1 sub for being the only correct character controller I've ever seen talked about.
@glx6377
@glx6377 Жыл бұрын
It's working thanks my friend
@xvdimmy8220
@xvdimmy8220 Жыл бұрын
This is gold!
@tasdude3227
@tasdude3227 3 ай бұрын
YOOOOOO THANKS MAN EXACTLY WHAT I WANTED!! THANKS!!!
@sidneiguerrero1
@sidneiguerrero1 Жыл бұрын
What a legend only one ad in the beginning . Your so damn underrated
@Sergeeeek
@Sergeeeek 5 ай бұрын
Thanks for your tutorials! I implemented a first person controller with this approach and it feels great, can walk over any terrain including other rigid bodies, even moving platforms! When landing a jump it crouches slightly due to the spring which feels realistic and satisfying. Got your game on Switch, looking forward to play it with friends this weekend :)
@patrickbateman4641
@patrickbateman4641 3 ай бұрын
im struggling to implement this for fps, could you give any pointers? ty
@Sergeeeek
@Sergeeeek 3 ай бұрын
@@patrickbateman4641 well I think this video explains it pretty well, what are you having issues with?
@AimlessGaming1
@AimlessGaming1 Жыл бұрын
Damn bro top tier content, I'm sure you had to visit multiple countries to produce a masterpiece like this
@Arcal-sx6ls
@Arcal-sx6ls Жыл бұрын
Thank you In the setup
@vishalsenapati3879
@vishalsenapati3879 Жыл бұрын
that was so use full! !
@margaritamoreno2076
@margaritamoreno2076 Жыл бұрын
Cool You really help me Well done!
@huseyindogan7404
@huseyindogan7404 2 жыл бұрын
Wonderful
@nolamo1496
@nolamo1496 2 жыл бұрын
awesome video! really helpful information!
@brandonsanchez2673
@brandonsanchez2673 Жыл бұрын
Thank you
@Carlos-dk2lt
@Carlos-dk2lt Жыл бұрын
bro thanks so much. dis video is tiless 3 years ltr n still great
@KokapaGameDev
@KokapaGameDev 2 жыл бұрын
thanks for sharing this is amazing
@LordHinson
@LordHinson Жыл бұрын
Amazing tutorial
@nthnnnnnnnnn
@nthnnnnnnnnn 3 жыл бұрын
Looks really cute
@RoffeDH
@RoffeDH 2 жыл бұрын
Hey, just created this Git repository with the assets I've created based on your tutorial. Just wanted to say thanks as this is EXACTLY what I was looking for.
@munyunu
@munyunu 2 жыл бұрын
Ahhh whereeee is the repo please?
@Jyotigupta399
@Jyotigupta399 Жыл бұрын
You train so well! It's like you comprehend my tempo...
@r.d.x8097
@r.d.x8097 Жыл бұрын
hanks lot Sir.. You helping us..
@angelrubiov
@angelrubiov 3 жыл бұрын
Fantastic
@ed_halley
@ed_halley Жыл бұрын
I got pretty much all of the controller stuff working except the jump force working. Because the character's on a spring and could be moving up or down at the time of the jump, I guess I need to do the "neededAccel" calculation to achieve a consistent starting jump velocity. And then also support the jump-hold to bring it up to a maximum velocity.
@mobilelegendlivetest2779
@mobilelegendlivetest2779 Жыл бұрын
I feel you!
@neustar9999
@neustar9999 Жыл бұрын
really cool!
@bahtiyarozdere9303
@bahtiyarozdere9303 3 жыл бұрын
Amazing ^^
@the_shade7663
@the_shade7663 Жыл бұрын
thanks
@mikuspl4475
@mikuspl4475 Жыл бұрын
Lots of love bro
@Paul-to1nb
@Paul-to1nb Жыл бұрын
Hi! Great video and blog! I was looking at the Character Animation blog post and I'm really confused about the "use an animation curve that defined how to move between single frame poses." I get the idea that you're blending between the poses, but I'm not sure how you can apply the animation curve to a pose.
@hichammarcelcoca8809
@hichammarcelcoca8809 Жыл бұрын
Great Game! I Downloaded It In My Nintendo Switch But In DEMO Version
@hits4209
@hits4209 Жыл бұрын
YES! I LOVE YOU!
@joseluisRueda
@joseluisRueda Жыл бұрын
great job 🙂
@TedThomasTT
@TedThomasTT 2 жыл бұрын
You guys are saints for sharing this knowledge
Instant "Game Feel" Tutorial - Secrets of Springs Explained
12:17
Toyful Games
Рет қаралды 17 М.
Что будет с кроссовком?
00:35
Аришнев
Рет қаралды 2,4 МЛН
Do you like a chocolate surprise egg?🥚🍫🥰 #demariki
00:32
白天使和小丑帮助黑天使。#天使 #超人不会飞 #超人夫妇
00:42
How To MAKE A Tycoon Game in Roblox Studio | Part 2 - Owner
10:39
Rustysillyband
Рет қаралды 49 М.
Why Stairs Suck in Games... and why they don't have to
11:24
Nick Maltbie
Рет қаралды 1,5 МЛН
Active Ragdolls; What Are They And How They Work
9:41
Birdmask Studio
Рет қаралды 39 М.
Создаю платформер с нуля на Unity (Corgi Engine). Урок #1 by Artalasky
26:03
ARTALASKY CG - Как создать игру
Рет қаралды 90 М.
How to Turn Movement into a Game Mechanic
13:27
Game Maker's Toolkit
Рет қаралды 830 М.
Jumping challenge with Herobrine
0:39
Big Monster School
Рет қаралды 11 МЛН
Who Will You Choose Bad Parents or Good Poor Zombie?
0:39
Realistic Craft
Рет қаралды 8 МЛН
Minecraft Japanese Mountain Temple Build Timelapse 🤯
0:41
CraftedGaming Shorts
Рет қаралды 74 МЛН
Glitch Larry & Lawrie is the new ranked skin ✅ #shorts #brawlstars
0:20