#Thread

1 messages · Page 1 of 1 (latest)

serene pendant
#

Okay let's go into a thread

placid mortar
#

sure, thanks so much for helping aswell

serene pendant
#

the animatorcontroller, can you check whether the states actually have animations?

placid mortar
#

sure

#

the thing is, its really annoying because it worked before & I have videos of it working

serene pendant
#

well that seems fine. Is the animatorcontroller assigned to an animator component on the model?

placid mortar
#

yep, let me show you that now

serene pendant
#

can you check

placid mortar
#

yep

#

the if statement was me checking if the animations work

serene pendant
#

did it?

placid mortar
#

playerAnim.SetTrigger doesn't work either

#

nope

serene pendant
#

put a debug there, see if the code gets called

placid mortar
#

alr sure

serene pendant
#

maybe you're not longer using the old Input system

#

idk

placid mortar
placid mortar
serene pendant
# placid mortar

by the way I don't see a state called 'idle', so that won't work

#

check if the triggers get set in the animatorcontroller during play mode

placid mortar
serene pendant
#

that's a trigger

placid mortar
#

ik and im setting the trigger

serene pendant
#

I was replying to the screenshot with Play("idle")

placid mortar
#

oh

#

i ran it with settrigger

serene pendant
#

okay so looks like it's running the animation there?

#

might want to set the animation to loop

placid mortar
#

its looping

#

already

serene pendant
#

ok

#

so what isn't working?

placid mortar
#

the animation

#

isn't playing

serene pendant
#

well it is playing, I can see that in the animatorcontroller. But the character isn't moving?

placid mortar
#

yeah

#

the animation runs in Microsoft 3D software - however.

serene pendant
#

Switching states works in the animatorcontroller?

placid mortar
#

uhh let me check that now

#

everything worked before

serene pendant
#

yeah I think the script is fine, the animatorcontroller is fine; but the animatorcontroller doesn't like the model hierarchy

placid mortar
#

yeah, the attack animation works in the controller - like it fires

#

but the animation just doesn't show

serene pendant
#

so, import settings or object hierarchy

#

is the animator on the correct gameobject

placid mortar
#

yeah

#

it is

#

i mean it should be

serene pendant
#

try opening the animation window again with the model selected in the scene hierarchy

placid mortar
#

shit

serene pendant
#

what gameobject is the Animator component on

placid mortar
#

the Player component

#

which is the uhh

#

i forgot the word

#

capsule

#

then the golem is the child of the capsule

serene pendant
#

Well this animation expects it to be on the golem

placid mortar
#

alright

serene pendant
#

put it on Golem_Pose

placid mortar
#

ill try to put it on the golem rn

#

how would I add the golem_pose animator to the Player object scripts

serene pendant
#

just assign Golem_Pose to the animator field on player

#

Player_Anim

placid mortar
#

alr

#

animations work now but the character doesn't move xD

serene pendant
#

turn 'apply root motion' on

#

although I have no idea how the movement speed and stuff from 'player' class is intended to be used

placid mortar
#

wheres that

serene pendant
#

on the animator

placid mortar
#

not going to lie to you I can't see apply root motion

serene pendant
placid mortar
#

oh alr

#

nope, nothing. I think this is my issue instead of yours because i just tested it again and the character doesn't move

serene pendant
#

yeah i don't know how it's supposed to move

#

maybe try putting all those scripts on the golem

#

instead of Player

placid mortar
#

kk

placid mortar
#

if that helps

#

nope.

serene pendant
#

the player script would be more helpful

placid mortar
#

the whole script?

#
using System.Security.Cryptography;
using System.Collections.Specialized;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

   #region Private Variables

    [SerializeField] private Animator playerAnim;
    [SerializeField] private float walkSpeed, originalSpeed, runSpeed, rotateSpeed;
    [SerializeField] private bool walking;
    [SerializeField] private  Transform tf;
    [SerializeField] private  Rigidbody rb;

    #endregion

    void FixedUpdate(){
        if(Input.GetKey(KeyCode.W)) {
            rb.velocity = transform.forward * walkSpeed * Time.deltaTime;
        }
        if(Input.GetKey(KeyCode.S)) {
            rb.velocity = -transform.forward * walkSpeed * Time.deltaTime;
        }
    }


    void Update(){
        walkin();
        rotating();
        attacking();
        ultimateSlam();

    if (Input.GetKeyDown(KeyCode.L)) {
        Debug.Log("Idle: setTrigger 1 ");
            playerAnim.SetTrigger("idle");
            Debug.Log("Idle: setTrigger 2 ");


        }
}


void walkin() {
if(Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.S)) {
            playerAnim.SetTrigger("walk");
            playerAnim.ResetTrigger("idle");
            walking = true;
        }


        if(Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S)) {
            playerAnim.ResetTrigger("walk");
            playerAnim.SetTrigger("idle");
            walking = false;

            rb.velocity = Vector3.zero;
            
        
        }

        if (walking && Input.GetKeyDown(KeyCode.LeftShift)) {
            playerAnim.SetTrigger("run");
            playerAnim.ResetTrigger("walk");
            walkSpeed = walkSpeed + runSpeed;
        }

        if (walking && Input.GetKeyUp(KeyCode.LeftShift)) {
            walkSpeed = originalSpeed;
            playerAnim.SetTrigger("walk");
            playerAnim.ResetTrigger("run");
            
        }
    }


    void attacking() {
    bool hasAttacked = false;

    if (Input.GetButtonDown("Fire1")) {    
        playerAnim.SetTrigger("attack");
        playerAnim.ResetTrigger("slam");
        hasAttacked = true;
        }

        if (playerAnim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1 && hasAttacked) {
            playerAnim.ResetTrigger("attack");
            hasAttacked = false;
        }

    }

    void ultimateSlam() {
        bool hasAttackedSlam = false;

        if(Input.GetButtonDown("Fire2")) {
        playerAnim.SetTrigger("slam");
        hasAttackedSlam = true;
        }

        if (playerAnim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1 && hasAttackedSlam) {
            playerAnim.ResetTrigger("slam");
            playerAnim.ResetTrigger("attack");
            hasAttackedSlam = false;
        }
    }

    private void rotating() {
        if(Input.GetKey(KeyCode.A)) {
            tf.Rotate(0, - rotateSpeed * Time.deltaTime, 0);
        }
        if(Input.GetKey(KeyCode.D)) {
            tf.Rotate(0, rotateSpeed * Time.deltaTime, 0);
        }

    }


        
}

serene pendant
#

looks like it's not using any root motion or whatever, just rigidbody

placid mortar
#

yeah

serene pendant
#

so that has nothing to do with the animations

placid mortar
#

yeah ik, I said i believe its on my end

serene pendant
#

it's all on your end 😛

placid mortar
#

you know what i mean silly

#

xD

#

my unity is also bugging out a LOT

#

strange, if i put the move code somewhere else it works

#

good news @serene pendant i got it back... SOMEWHAT

#

omg this is so weird 🤣