How to implement a speed boost on-screen buton?
I am making a game for Android and I want to implement a speed boost button for my player. Can anyone help me out? I don't know what to write in the script for it to work.
That is my movement script (I am using a joystick) :
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class JoyMov1 : MonoBehaviour
{
protected Joystick joystick;
// Start is called before the first frame update
void Start()
{
joystick = FindObjectOfType<Joystick>();
}
// Update is called once per frame
void FixedUpdate()
{
var rigidbody = GetComponent<Rigidbody>();
rigidbody.velocity = new Vector3(joystick.Vertical * -4000f * Time.deltaTime,
rigidbody.velocity.y,
joystick.Horizontal * 4000f * Time.deltaTime);
}
}
Thanks !
Comment
Your answer
Follow this Question
Related Questions
How to add dash to my character in Unity 3D? 0 Answers
Speed boost button for player 0 Answers
Android App Crashes Randomly 0 Answers
Help with drift physics 0 Answers