playMaker

Author Topic: animator and movement  (Read 985 times)

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
animator and movement
« on: June 21, 2023, 03:58:13 AM »
Hello, I have a problem, I'm doing several tests in unity, following some tutorials I created a character whose movement logics are in an empty parent object called player simply including the character controller, now ... everything works fine except one thing, i have an animation of vaulting over an obstacle...this animation runs just right and everything seems to be where it should be....the problem is that actually the character controller collider and all its elements don't follow the movement of the animation while remaining distant ... so I tried to do several tests ... through actions by checking the position with get position ... of each object and even of the animator and although visually it seems to move in reality the positions do not change, I apologize if I was not clear but I'm a total beginner and I hope I have made the idea...

I noticed that if I do everything on the same gameobject without using a parent for the logic everything works correctly and even through the animation editor I can easily modify the collider according to the animations of my character ... but in this specific case I would like to know how I can do....thank you very much
« Last Edit: June 21, 2023, 04:03:02 AM by katanant »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: animator and movement
« Reply #1 on: June 21, 2023, 06:38:14 AM »
Hi.
Having all on 1 object is probably the main issue.

I don't use character controller as i make my own (also I am in 2D).
My controls are root (using velocity for movement) , and animations as a child.
in animator have a float parameter for move speed and I use Get velocity and Set Animator Float.

Then I have the float parameter connected to handle animation speed / Idle / Walk / Run

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #2 on: June 21, 2023, 03:12:05 PM »
hello, my "project" is in 3d and I'm also using a blend tree for movement actually only for idle and walk, I did the run separately, the walk starts when the blend float is greater than zero and I associated it with magnitude stored in a variable so I also used set animator float😊.....doing some tests however I think I prefer a classic rigidbody and a Collider to the character controller and character simple move...I have the impression of having more control over everything but I repeat I'm a beginner .... tonight when I get back from work I try to make a video of what happens .... just to understand, for me it's still a study and I would like to understand the problem. ... thanks for answering anyway 👍🏻

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #3 on: June 21, 2023, 05:24:01 PM »
I post two videos, seeing what happens is worth a thousand explanations... :)


in the first video the player walks, runs, jumps and rolls on the ground after jumping only and only after a run, and so far so good


the problem arises here, i haven't added any script or fsm yet to control the vault animation but i started it by manually setting vault to true in the animator just to show what happens, as you can see the model moves but the collider and that is the character controller remains in the starting position causing many problems ...

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: animator and movement
« Reply #4 on: June 21, 2023, 05:39:16 PM »
Hi.
Maybe its on the animation settings?



I don't have much experience with 3D character, you could try joining discord.
there are many friendly peeps that help each other out there :)

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #5 on: June 21, 2023, 06:01:14 PM »
I've already tried, I just unchecked root transform position (xz) bake into pose...nothing always the same, thanks for the tip....I've never used discord I'll try

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: animator and movement
« Reply #6 on: June 21, 2023, 06:03:52 PM »
The discord server has around 1000 members and a 350 average online all day/night

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #7 on: June 21, 2023, 06:09:49 PM »
I'm seeing it right now, I had never taken it into consideration because being Italian and not having a great understanding of the English language it takes me a while to translate XD

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #8 on: June 22, 2023, 05:43:55 AM »
good morning, I would like to share the solution that worked for me if it were to help someone inexperienced like me, in this case I used a simple script, the problem was that using bake into pose in the clip options the movement was only about the animation and not the object itself in this case "Vampire" where the animator resides, this solved the problem was that actually the real root was in the parent object "player" so it was necessary to transmit the position of "vampire" to player and this is possible thanks to the OnAnimatorMove() method in c#... I share the script...

Code: [Select]
// this component should be attached on the same GameObject of the Animator
public class RootMotionRelay : MonoBehaviour
{
    [SerializeField] private Animator animator;
    // your real root
    [SerializeField] private Transform playerRootTrs;
 
    private void OnAnimatorMove()
    {
        // you have to adjust this moving part to your CharacterController version
        playerRootTrs.position += animator.deltaPosition;
        playerRootTrs.rotation = animator.deltaRotation * playerRootTrs.rotation;
    }
}

questo ha funzionato alla grande per me applicato all'oggetto contenente l'animator...ora sarei curioso di replicarlo in playmaker ;)

katanant

  • Playmaker Newbie
  • *
  • Posts: 12
Re: animator and movement
« Reply #9 on: June 23, 2023, 03:34:08 AM »
i realized i wrote in italian the last two lines in the previous post ;D....what i meant was..."this worked great for me applied to the object containing the animator...now i'm curious to replicate it in playmaker "


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: animator and movement
« Reply #10 on: June 23, 2023, 08:19:52 AM »
Hi.
Look to some existing actions.

mainly in playmaker scripts, the variable types are call FsmInt / FsmFloat / etc.

but you can use also normal variables, the only downside is that you can not set a playmaker variable to it.

There are different type of actions, this one suits for a FsmStateActionAnimatorBase or component action. (see Class line)
Look to the action "Get Animator Delta"