I need help using the UI buttons in my code and also why my code isn’t working!
The Debug.Log
works but the jump isn’t working and I don’t know y
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public Rigidbody2D rigidBody;
public FloatingJoystick joystick;
public Animator animator;
public CharacterController2D controller;
public Button button;
public float moveSpeed;
float horizontalMove = 0;
bool jump = false;
public void isJumping()
{
jump = true;
Debug.Log("porop");
}
private void FixedUpdate()
{
//rigidBody.velocity = new Vector2(joystick.Horizontal * moveSpeed, rigidBody.velocity.y);
controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
//jump = false;
}
private void Update()
{
horizontalMove = joystick.Horizontal * moveSpeed;
animator.SetFloat("Speed", Mathf.Abs(joystick.Horizontal));
}
}