three.js Basic Character Controls - GLTFLoader, AnimationMixer, 3rd Person Controller

Поділитися
Вставка
  • Опубліковано 24 лип 2024
  • We build some basic character movement controls, using W,A,S,D we can Idle, Walk and Run. Implement a character state machine, with smooth animation transitions using AnimationMixer. Build a 3rd person controller with three.js!
    Check out the next video, character movement with physics: • three.js & rapier3D - ...
    Stackblitz: stackblitz.com/github/tamani-...
    Github: github.com/tamani-coding/thre...
    (00:00) - Intro
    (00:36) - Scene Setup
    (00:50) - Key Listener
    (01:30) - GLTFLoader to Load the Model
    (02:18) - Use AnimationMixer & AnimationActions
    (02:50) - Character Controls State Class with Default State
    (05:00) - State and Animation Transition (FadeIn/FadeOut)
    (06:32) - Turn Character Model towards Run Direction
    (07:50) - Move Character and Camera
    (09:00) - Outro
    (music from: en.pocket-se.info/)
  • Наука та технологія

КОМЕНТАРІ • 54

  • @losrobbosful
    @losrobbosful 11 місяців тому +2

    Exactly the video walkthrough needed. Finally a very clean and straight-forward explanation of the process. I love it. Will checkout more of your stuff :)

  • @kerrykreiter445
    @kerrykreiter445 6 місяців тому

    one of, if not the best Threejs tutorials I've seen on UA-cam. Thanks so much!!

  • @amalnathsathyan6029
    @amalnathsathyan6029 2 роки тому +2

    That background and the soothing voice, What a nice place to learn to code!!

  • @losrobbosful
    @losrobbosful 8 місяців тому +2

    2 years have passed. And even though quite complex, this stuff is still the most clean & complete video tutorial on third person follow camera in ThreeJS.
    Hope at some point & enough repetitions I will completely understand the code :D
    Actually it would be great to have a separate video just on the camera movement & quaternion rotation stuff, which goes a bit slower :) That would be of insane help. Because here good walkthroughs just like yours are still lacking at YT

  • @anaymittal7720
    @anaymittal7720 2 роки тому +2

    Yesssss thank you!!

  • @smackdownboy
    @smackdownboy Рік тому

    This is really a good video. Every concept is taught so easily and clearly.

  • @jpjpjpjpjpjpjpjp
    @jpjpjpjpjpjpjpjp 2 роки тому +2

    Love the video, super helpful for getting started on a threejs game. may I request movement on terrain for a future video topic?

  • @kinsukaweerasooriya2933
    @kinsukaweerasooriya2933 5 місяців тому

    Thank you very much Sir !

  • @johnpaulganzan1731
    @johnpaulganzan1731 2 роки тому

    Thank you Very much!

  • @HuynhLuong227
    @HuynhLuong227 Рік тому

    that's amazing

  • @howl2339
    @howl2339 Рік тому

    If only there were the words to describe how wonderful there tutorials are

  • @ujeeblends
    @ujeeblends 2 роки тому

    thanks a lot!

  • @jiweizhang3565
    @jiweizhang3565 2 роки тому

    讲的真好

  • @nomiscph
    @nomiscph Рік тому

    Amazing video, i was wondering do you have any suggestions on how to do the same movements but by mouse click as in diablo 2 :)

  • @user-zn1jj8nj1j
    @user-zn1jj8nj1j 2 роки тому

    Cooooooool

  • @BhanuPratap-ss3ep
    @BhanuPratap-ss3ep 5 місяців тому

    very good tutorial , please upload videos regarding game dev in threejs

  • @christophkrass6929
    @christophkrass6929 2 роки тому

    vielen Dank

  • @juangoyret9364
    @juangoyret9364 Рік тому +5

    Amazing work, it will be awesome that you convert it to a library that anyone can import and the only thing to put as a parameter is the model, the animations names and a delta speed maybe. I think that threejs has a enormous potential if we start as a community to create libraries that makes more friendly the game developing. I think that threejs can compite with Unity or any game engine that allows you to develop in the browser.

  • @neelmistry9241
    @neelmistry9241 Рік тому

    Amazing explanation, But can you please explain how to set the controls on html button click for mobile device access?

  • @elingaldo
    @elingaldo Рік тому

    simply billiatn c:

  • @vineetjana6393
    @vineetjana6393 Рік тому

    can you help me with getting the changing position of the model in the index ts file...I cannot export the position to the index file ...plz help

  • @Cat_trot2333
    @Cat_trot2333 2 роки тому +1

    nice video ! hi bro , can you make a montage motion lesson by three .js ? like roll or attack

  • @webghoul
    @webghoul 2 роки тому

    there is any error where us used the object method to store which key is pressed in event listener :
    error is here : (keypressed as any)[event.key.toLowerCase()] = true
    error : Uncaught SyntaxError: Unexpected identifier

  • @Ajion
    @Ajion 2 роки тому +7

    good choice of music lol

  • @xbz24
    @xbz24 10 місяців тому

    gracias

  • @michaelmas2841
    @michaelmas2841 2 роки тому

    Hello, great job! I have question: can i use arrow keyboard for the control of model?

    • @michaelmas2841
      @michaelmas2841 2 роки тому

      It's ok : Can use arrowup, ect... for it!

  • @siddhipatil9648
    @siddhipatil9648 19 днів тому

    Can we add this to Aframe scene

  • @jesusmuhammad8220
    @jesusmuhammad8220 2 роки тому

    really helpful tutorial! Thank you. I got one problem: I wanna to have a camera which is not following the character, how should I set the walkDirection? :/ For now, the moving direction has some issue...

    • @heygenka
      @heygenka  2 роки тому +1

      In a third person camera the walking direction depends on the camera direction. In your case the camera is positioned independently of the character so the character movement direction depends on some global direction axis

    • @weslleymatheus3643
      @weslleymatheus3643 2 роки тому

      @@heygenka Hi man, I downloaded the entire "src" folder of your code, without changing anything. But it's giving an error.
      in this part the parts in quotes, turn red.
      import { KeyDisplay } from './utils';
      import { CharacterControls } from './characterControls';
      import * as THREE from 'three'
      import { CameraHelper } from 'three';
      import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
      import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
      in this one, too.
      import * as THREE from 'three'
      import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
      import { A, D, DIRECTIONS, S, W } from './utils'
      Would you help me???
      i am braziliam. My english is not very good, sorry.

  • @cryptoMateMSGP
    @cryptoMateMSGP 2 роки тому

    would you be keen to work for us animating a scene that we already have?

  • @danielvaldecantos3629
    @danielvaldecantos3629 Рік тому +1

    the animations don't work if you create a constant elapsedTime variable before creating the mixerUpdateDelta variable.
    weird.

  • @uRealReels
    @uRealReels 5 місяців тому

    how do i use npm to run this?

  • @clockssss
    @clockssss 11 місяців тому

    How would you be able to make it work on mobile?

  • @nguyentuantruong4815
    @nguyentuantruong4815 Рік тому

    you can explain in the code:
    var angleYCameraDirection = Math.atan2(
    (this.camera as THREE.Camera).position.x -
    (this.model as THREE.Group).position.x,
    (this.camera as THREE.Camera).position.z -
    (this.model as THREE.Group).position.z
    );
    At the 6:44 th minute video. I really don't understand why subtract the two coordinates together? I have learned about Math.atan2() function but still don't understand what you do in that part

  • @harsh_here
    @harsh_here 2 роки тому

    Can we have a 3rd person camera effect whicy can be controlled using Wasd without having any character?

    • @antoniofuller2331
      @antoniofuller2331 2 роки тому

      Obviously yes, it's right in front of you

    • @harsh_here
      @harsh_here 2 роки тому

      I meant controlling camera with WASD

    • @user-cz9ey8hn9g
      @user-cz9ey8hn9g Рік тому

      @@harsh_here Is this a forward camera projection?

  • @mohammadaamirkhan3359
    @mohammadaamirkhan3359 2 роки тому +1

    i need source code plz

  • @ethanendures
    @ethanendures Рік тому

    thanks, this can be implemented in react-three/fiber.

    • @Unfair_Rabbit
      @Unfair_Rabbit Рік тому

      you got any solutions ?

    • @ethanendures
      @ethanendures Рік тому

      @@Unfair_Rabbit hi, I implemented this in react-three/fiber, but I got some bugs. I am learning and trying to get this implemented into 7878(rust) programming language 🚀,
      1. Follow the exact same steps as he shown but with react three fiber
      2. Some assignments must be done with useState, for example : const [velocity, setVelocity] = useState(THREE.vector(0,0,0));
      3. The animations I did were done on blender, Note to change the name of the actions and actually know what actions are set in blender for your amarture.
      1. Go to Blender
      2. Load in your model (fbx, or glb, etc..)
      3. Click your amarture and go right above the Scene Collection and you should see two dropdowns ( one looks like a file system structure, and the one next to it looks like an picture frame with a mountain and a tiny moon in it.
      4. click on the dropdown with the picture frame, and select Blender FIle
      5. Then select actions,
      3.A. you can look up how to work with loading animations with blender and mixamo.
      4. I just translated the code from the video to react.
      Lastly, this is a good video to learn how to control a 3rd person camera correctly in threejs.

    • @Unfair_Rabbit
      @Unfair_Rabbit Рік тому

      @@ethanendures maybe i can try fixing those bugs if you can provide your code to me

  • @djiduthID
    @djiduthID Рік тому

    please full tutorial sirr

  • @catdsnny
    @catdsnny Рік тому

    Sample code doesnt work - wont build with node

  • @webghoul
    @webghoul 2 роки тому

    create the same for javascript please

  • @uRealReels
    @uRealReels 5 місяців тому

    where is index.Js in git... i only saw index.Ts

  • @amirreza3638
    @amirreza3638 6 місяців тому

    i loved the video, but it seems so complicated