Welcome, Guest! Login | Register
i'm retarded and i don't understand how to use animators
Info
Report
203 Posts

so, here's what's happening
i have attached this animator to an object and in this same object i attached a script that theoretically should order the object to do this animation inside the animator whenever the tagged object touches it
problem is it doesn't work, the process just does not start
i have verified for sure that the tagged object does indeed touch the scripted object for long enough where its impossible that it would not detect it so im gonna assume im doing something wrong here but i cant understand what
Created on: 1 month ago
Info
Report
210 Posts

I recommend you to check the following things:
- Does your animation have frames? If it does, Is the sample count above 1?
- Does the animation you want to play have a speed above 1?
- Does your state contain the animation you want to play?
- Is the GameObject with the Animator active? Is the Animator on the GameObject active too?
- I see you used " to specify the animation name, check it on both the Animator and the Script, maybe you misspelled it?
-You could also check the collider and the tag on the objects too.

A quick tip: Instead of collider.gameobject.tag == "Something", use collider.gameobject.CompareTag("Something"). I heard its a bit better than just == these guys


I also recommend you to have the model with the Animator under a GameObject. So that the main GameObject has the scripts, along with the model having the animations. This will let you move it around a bit more freely!

Also, be sure to ask here anything regarding Unity. I can probably help out with the more basic & intermediate stuff, probably? Do NOT try to ask around the Unity Forums, you rarely get an answer, if you ever even get answers. You can search up forum posts they already answered, but I don't recommend writing posts there, do it here instead
Created on: 1 month ago
Edited on: 1 month ago
Info
Report
203 Posts

@doomer022

damn really? is there not a bigger community where people exchange advices other than the unioty forums that you visit?

well back on topic

-yep, if frames are what i think they are. and no, i can't even find a way to count them.
-yep
-yep
-yes and yes
-watching the animator while i play the game the animation technically is working, but it won't show
-already did

at this point it must be something related with the sample i think
Created on: 1 month ago
Info
Report
210 Posts

@timestopdev Weird, your Unity version's Animator window doesn't even show the Sample rate! I guess it must be 60, the default value, which is what I use. But...the Animator won't show? It should get the Animator because you cant assign it by yourself because it's not public.

Hmm...Maybe you could put a whole bunch of Debug.Log commands that will print stuff to the console. So when you press a button, you could write "Debug.Log("Button pressed!")" or something like that. Put that over the parts of the code where you think it would be going wrong, tho I don't think its actually the code. It seems fine to me at least. But you can try. Also, sometimes you might get stuck at the smallest little details because it went over your head. Happens to me all the time
Created on: 1 month ago
Info
Report
203 Posts

well now, ive tried writing a different script, one for an input and one for the tag

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BOTTA : MonoBehaviour
{
  

    Animator coso;

    void Start()
    {
        coso = GetComponent<Animator>();
    }

    void OnTriggerEnter(Collider collider)
    {

        if (collider.gameObject.CompareTag("Ground"))
            coso.SetBool("punched", true);
        else
        {
            coso.SetBool("PUNCHED", false);

        }

    }

    private void Update()
    {
        if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow))
        {
            coso.SetBool("PUNCHED", true);

        }

        else
        {
            coso.SetBool("PUNCHED", false);

        }
    }
}

the problem seems to be related to collisions somehow, because while the input one works just fine,  no matter what tag or object i set, it just doesn't  detect it
i'll look into this
Created on: 1 month ago
Info
Report
47 Posts

Hi Upper and lower case can not be mixed you must have one or other. Unless these 2 SetBool() are for different uses.

n_iron


Quote: the problem seems to be related to collisions somehow,

        if (collider.gameObject.CompareTag("Ground"))
            coso.SetBool("punched", true);
        else
        {
            coso.SetBool("PUNCHED", false);

        }
Created on: 4 weeks ago
Edited on: 4 weeks ago
Info
Report
203 Posts

@niron LOL don't know how that escaped me
that still doesn't seem to be the problem tho, even after correcting it, the collision doesn't work,  meanwhile the input does
Created on: 4 weeks ago
Info
Report
210 Posts

@timestopdev Hmm...Maybe check the collider if it's not marked as a trigger?
Created on: 3 weeks ago
Info
Report
47 Posts

Hi you can't have a collider for physic and a trigger at the same time.

n_iron
Created on: 3 weeks ago
Reply
Preview
Post
Or use the advanced reply form here...
Sponsored