Question by
IronDragonDev · May 23, 2020 at 07:18 PM ·
c#buttonhold
How can i make a hold method for addforce?
Hi, I'm new in unity I have a small issue I've tried to make a hold method for my button the button is working but the hold method is not if anyone can help me I'll be so thankful,this is my code
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems;
public class LeftTouch : MonoBehaviour {
public Rigidbody rb;
public float sideWays = 700f;
public void OnPointerDown()
{
rb.AddForce(-sideWays * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
public void OnPointerUp()
{
rb.AddForce(0, 0, 0, 0);
}
}
capture.png
(247.7 kB)
Comment