- Home /
Question by
fallofdays · Sep 15, 2020 at 04:05 PM ·
2dscripting problemanimationsscript reference
Adding jump animation in script editor [2D Project]
Hi everyone, newbie here. I'm currently working on my first project that is basically a flappy bird lookalike game. I have a character in the scene and when I press the LMB he jumps but I don't know how to switch from the run cycle to the jump animation in the script editor. If anyone culd help me by sending some reference script or some video tutorial would be amazing. I'll leave my script down below. Tnx 4 the help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_jump : MonoBehaviour
{
public Animator animator;
public float velocity = 1;
private 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.GetMouseButtonDown(0))
{
//Jump
rb.velocity = Vector2.up * velocity;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
UDP app signature? 1 Answer
Make my mathf to Wait? :) 2 Answers
How to lock FPS? 1 Answer
Get Animator current Animation using script ? Possible ? 0 Answers
Getting Sprites to Face Eachother (building on 2D Platformer tut) 0 Answers