Hey guys.
I’ve modified the headlook controller itself in C#. Every single code that’s being used in my project is written with JS, except for the HeadLook Controller. I can’t do the simplest thing; avoiding the Player tag.
using UnityEngine;
using System.Collections;
public class CursorHit : MonoBehaviour {
public HeadLookController headLook;
// public Transform Player;
private float offset = 3.5f;
//public LayerMask mask = 9;//1 << 8;
public LayerMask mask = 6;
// Update is called once per frame
void LateUpdate () {
//
// int AimRaycast = 8;
//int AimRaycastMask = 1 << AimRaycast;
if (Time.timeScale == 1.0) {
if (Input.GetKey(KeyCode.UpArrow))
offset += Time.deltaTime;
if (Input.GetKey(KeyCode.DownArrow))
offset -= Time.deltaTime;
offset = Input.GetAxis("Mouse Y");
Ray cursorRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(cursorRay, out hit)) {
transform.position = hit.point + offset * Vector3.up;
Screen.lockCursor = true;
// Physics.IgnoreCollision(Player.collider, collider);
// print(LayerMask.LayerToName(8));
}
headLook.target = transform.position;
}
}
}
I can do this just fine in JS, but everything is done a little differently in C#.
I want the raycast done here to avoid/ignore any object with the “Player” tag.
Can anyone help me?
Thanks in advance.