#that problem

1 messages · Page 1 of 1 (latest)

warm solar
cobalt tundra
#

To make a animation stop playing you have to uncheck "loop" on the file

warm solar
#

also slow internet so the video is taking time

#

maybe slow discord

cobalt tundra
#

the-animation.anim

warm solar
cobalt tundra
warm solar
#

thats not my problem

#

its a run animation ofc i want it looped

#

just wait for the vid see what the problem is

cobalt tundra
#

Alrighty. Show the code then?

#

In the animation controller you should have a start and end

warm solar
# cobalt tundra Alrighty. Show the code then?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private Rigidbody2D rb2D;
    
    // player movement stuff
    private float MoveSpeed;
    private float JumpForce;
    private bool IsJumping;
    private float MoveHorizontal;
    private float MoveVertical;
    
    // player animation stuff with code hehehe
    private Animator animator;


    // Start is called before the first frame update 
    void Start()
    {
        rb2D = gameObject.GetComponent<Rigidbody2D>();
        animator = gameObject.GetComponent<Animator>();
        
        MoveSpeed = 3f;
        JumpForce = 60f;
        IsJumping = false;
    }

    
    // Update is called once per frame
    void Update()
    {
        MoveHorizontal = Input.GetAxisRaw("Horizontal");
        MoveVertical = Input.GetAxisRaw("Vertical");
    }

    
    void FixedUpdate()
    {
        if (MoveHorizontal > 0.1f || MoveHorizontal < -0.1f)
        {
            rb2D.AddForce(new Vector2(MoveHorizontal * MoveSpeed, 0f), ForceMode2D.Impulse);
            animator.SetFloat("PlayerSpeed", 1);
        }

        if (!IsJumping && MoveVertical > 0.1f)
        {
            rb2D.AddForce(new Vector2(0f, MoveVertical * JumpForce), ForceMode2D.Impulse);
        }
        
    }

    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Platform")
        {
            IsJumping = false;
        }
    }

    
    void OnTriggerExit2D(Collider2D col)
    {
        if (col.gameObject.tag == "Platform")
        {
            IsJumping = true;
        }
    }

    private bool IsAnimationPlaying(Animator animator, string stateName)
    {
        if (animator.GetCurrentAnimatorStateInfo(0).IsName(stateName) &&
            animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

cobalt tundra
#

It seems you made the animation play but never chose the idle animation again

warm solar
#

but

#

wait

#

@cobalt tundra im not choosing any other animation, i am just adding up a number with my code for the animation to play in the animator controller thingy

cobalt tundra
#

There should be two animations, idle, and walk, even if idle is just standing still

#

your controller is fine

warm solar
#

yes there are two

#

i know the problem is that it does not go back to 0 after i make it 1

#

i turn the animation into the run animation but i dont know how to revert it

cobalt tundra
#

Did you add conditions to the controller nodes?

warm solar
cobalt tundra
#

one sec ill grab a article online thatll show it

warm solar
#

i will look into that

warm solar
#

it is doing exactly what im missing

#

the direction thing

#

ill keep you updated

cobalt tundra
#

Yea np!

warm solar
#

thanks for the help till now

cobalt tundra
#

What you miss is you enable your walk but you never tell it to go back to idle, or dont have a fallback

warm solar
#

im guessing the jump is just an any state one?

#

i have a ground check

#

so

#

when im in the air i will jump

#

and when im not it will stop

#

right?

#

something like that

cobalt tundra
warm solar
#

but a small question

#

what does this mean

#
UnityEngine.Debug:LogError (object)
Unity.Services.Analytics.AnalyticsServiceInstance:.ctor () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/AnalyticsServiceInstance.cs:55)
Unity.Services.Analytics.AnalyticsService:.cctor () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/AnalyticsService.cs:7)
UnityEngine.GameObject:AddComponent<Unity.Services.Analytics.AnalyticsLifetime> ()
Unity.Services.Analytics.ContainerObject:Initialize () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/Runtime/AnalyticsLifetime.cs:88)
#

its this

#

what is the could project

cobalt tundra
# warm solar what does this mean

That is not important unless you are using cloud services for ADS, IAP, Analytics etc. If you are then your project is not linked with unitys dashboard

warm solar
#

cloud

cobalt tundra
warm solar
#

and its kinda annoying, can i turn it off?

warm solar
cobalt tundra
warm solar
cobalt tundra
warm solar
cobalt tundra
#

Just click one

#

Do the ads one

warm solar
cobalt tundra
#

Yea press configure

#

Should show a menu that may contain other settings

warm solar
#

it does not

#

it brings me to the ads service

cobalt tundra
#

Then click the cloud icon on the top left

#

Can configure it

warm solar
warm solar
#

@cobalt tundrahi there, so i tried the link you sent me

#

now the animation works it moves when i move and stops when i do stop

#

but

#

it does not turn

#

the blog says "you should place this code where you determine the direction of the player."

#

but i dont do that

#

does it mean this part?

warm solar
#

that problem

#

@cobalt tundra any ideas whats the matter?

cobalt tundra
warm solar
#

read what i said

#

it does use a direction thing

#

idk how i have to use it cuz i dont use a direction in my movement

cobalt tundra
#

Dont use that code if you dont use direction