How would I go about making RuneScape like movement where you point and click and the player moves to a location. How would the “point and click” style because the mouse works on x,y yet the player is in x,y,z…
much apreciated.
How would I go about making RuneScape like movement where you point and click and the player moves to a location. How would the “point and click” style because the mouse works on x,y yet the player is in x,y,z…
much apreciated.
Hi Thornekey, I Believe you want to use raycasting and check where the ray hits the plane/terrain that your character is moving on.
I’m newb myself so I can’t give you exact details, but you can check out this!
I believe this code could help. Just a sample I found on Google but I think it’ll give you the position you need.
// Unity 3D example picking a target position on a terrain using the mouse cursor using ray casting
using UnityEngine;
using System.Collections;
public class MouseTarget : MonoBehaviour {
void Update ()
{
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Terrain.active.collider.Raycast(ray,out hit,Mathf.Infinity))
{
transform.position = hit.point
}
}
}
Found at Unity 3D picking target position on terrain with mouse c# - Pastebin.com