I started a month ago with unity. I am curently working on the animations and playermovement.
Here is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playermovement : MonoBehaviour
{
public CharacterController2D controller;
public Animator animator;
public float runSpeed = 40f;
float horizontalMove = 0f;
bool jump = false;
// Update is called once per frame
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
animator.SetFloat("speed", Mathf.Abs(horizontalMove));
if (Input.GetButtonDown("Jump"))
{
jump = true;
animator.SetBool("IsJumping", true);
}
}
public void Onlanding()
{
animator.SetBool("IsJumping", false);
}
void FixedUpdate ()
{
controller.Move(horizontalMove * Time.fixedDeltaTime ,false , jump);
jump = false;
}
}