using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
public Animator animator;
public bool isjumping;
public float JumpForce=20f;
public float speed;
public Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Jump")&& isjumping==false)
{
Jump();
}
[COLOR=#ff0000]animator.SetFloat("speed", Mathf.Abs(????);[/COLOR]
rb.velocity= new Vector2(Input.GetAxis("Horizontal") * speed, rb.velocity.y);
if(Input.GetButtonDown("Fire1"))
{
rb.velocity = new Vector2(rb.velocity.x, speed);
}
}
void Jump(){
Vector2 movement = new Vector2(rb.velocity.x, JumpForce);
rb.velocity = movement;
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Floor"))
{
isjumping= false;
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("Floor"))
{
isjumping= true;
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("coins"))
{
Destroy(other.gameObject);
}
}
}
Hi recently i've been working on animating my character, and i reached to the parantheses what shoul
What is the question exactly?
I think he’s asking if he’s done the code right?
But there isnt any animation code lol
i made an animation code colored with blue
what shall i put in the parantheses
pls help me fast im in a game jam
Owhh, that was very unclear lmao
rb.velocity should be your speed right?
Otherwise just use trigger animations
can you send me any example
im 12 years old
can you give me examples
im only 12
Good that you are starting to code young but I’m not going to do someone elses work
at least just explain it more
“im not using you for codes”
Remove the mathf.abs with RigidBody.velocity if you have an animation setup