This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
project-undercover/Project Undercover/Assets/Scripts/Spy/PlayerController.cs

42 lines
1.1 KiB
C#
Raw Normal View History

using UnityEngine;
2017-09-13 17:29:22 -05:00
using System.Collections;
public class PlayerController : MonoBehaviour
{
2017-09-13 17:29:22 -05:00
public GameObject particle;
public GameObject cameraRigPrefab;
private GameObject cameraRig;
public Transform cameraTarget;
private Vector3 target;
private Spy spy;
private int mask;
2017-09-13 17:29:22 -05:00
void Start()
{
int layerMask = LayerMask.NameToLayer("Floor");
mask = 1 << layerMask;
spy = GetComponent<Spy>();
cameraRig = Instantiate(cameraRigPrefab, Vector3.zero, Quaternion.identity);
cameraRig.GetComponentInChildren<ThirdPersonCameraController>().SetTarget(cameraTarget);
2017-09-13 17:29:22 -05:00
}
void Update()
{
2017-09-13 17:29:22 -05:00
RaycastHit hit;
if (Input.GetButtonDown("Fire1")) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100.0f, mask)) {
2017-09-13 17:29:22 -05:00
Vector3 wantedPos = hit.point;
Instantiate(particle, wantedPos, Quaternion.Euler(-90,0,0));
wantedPos.y = 0.5f;
spy.UpdateTarget(wantedPos);
2017-09-13 17:29:22 -05:00
}
}
if (Input.GetKeyDown("space"))
{
spy.HandShake();
}
}
}