- Home /
Question by
Tubestorm · May 14, 2020 at 12:59 PM ·
uidestroytimertime.deltatime
Deal damage as player moves. need help!
Hello!
i'm trying to deal damage to my characters energy, by calculating the time it takes for them to go from current position to their destination.
problem is that this is a mobile app game, so the control is clicking on the screen to make the character move.
can someone advice me on how to do this, essentially the is moving function checks if what was clicked is not an Interact-able Object and moves the character to it, if it is not. i've tried a couple of things but no success.
public void IsWalking()
{
Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit interactionInfo;
if (Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
{
GameObject interactedObject = interactionInfo.collider.gameObject;
if (interactedObject.tag == "Interactable Object") //if the area is not an object do something
{
Debug.Log("we clicked on something");
}
else
{
Debug.Log("THIS SHIT IS MOVING");
}
}
}
Comment