You are on page 1of 1

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyScript : MonoBehaviour


{
protected Joystick joystick;
protected Joybutton joybutton;
protected bool jump;

// Start is called before the first frame update


void Start()
{
joystick = FindObjectOfType<Joystick>();
joybutton = FindObjectOfType<Joybutton>();

// Update is called once per frame


void Update()
// Script-ul de a se misca caracterul conform touchcontrollului
{
var rigidbody = GetComponent<Rigidbody>();

rigidbody.velocity = new Vector3(joystick.Horizontal * 5f,


rigidbody.velocity.y, joystick.Vertical * 5f);

// Sistemul de jump
if(!jump && joybutton.Pressed)
{
jump = true;
rigidbody.velocity += Vector3.up * 5f;

if(jump && !joybutton.Pressed)


{
jump = false;
}
}
// Cursorul nu va mai ramane blocat
void UnLockMouse()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}

You might also like