Skip to content
Permalink
e196abb75f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
44 lines (34 sloc) 1.06 KB
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
//Declaration
public GameObject player;
public float xPos;
public float zPos;
public Vector3 playerPos;
public float distance;
public Ray ray;
public RaycastHit hit;
public Vector3 travel;
// Update is called once per frame
void Update ()
{
xPos = Input.mousePosition.x;
zPos = Input.mousePosition.z;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(1))
{
if (Physics.Raycast(ray, out hit))
{
travel = new Vector3(hit.point.x, .5f, hit.point.z);
xPos = hit.point.x;
zPos = hit.point.z;
}
playerPos = new Vector3(xPos, 0.5f, zPos);
iTween.MoveTo(gameObject, playerPos, distance);
distance = Vector3.Distance(travel, transform.position);
}
playerPos = new Vector3(xPos, 0.5f, zPos);
// player.transform.position = playerPos;
}
}