I wanna cast a ray from the computer sprite you see in the background. The ray should detect if theres the player infront of it.
The ray should be casted in the viewers direction. As you can see it isn’t.
In the code, the computer sprite is nonPlayableObject
using UnityEngine;
using DialogueEditor;
public class Actions : MonoBehaviour
{
public void OpenTextbox(GameObject nonPlayableObject)
{
Debug.Log("Searching for player");
Debug.DrawLine(nonPlayableObject.transform.position, nonPlayableObject.transform.forward, Color.red, 1);
if (Physics.Raycast(nonPlayableObject.transform.position, nonPlayableObject.transform.forward, 1))
{
NPCConversation myConversation = nonPlayableObject.transform.GetChild(0).gameObject.GetComponent<NPCConversation>();
ConversationManager.Instance.StartConversation(myConversation);
Debug.Log("Dialogue started");
}
}
}
I already tryed using vector3.forward, vector3.up and vector3.back to check whats wrong, but the raycast didn’t change at all.
Additional Info:
Im using an asset from the asset store called “Dialogue Editor”.
The ray is always casted between the computer sprite and -6.5,-7.5, 11
Does anyone have an idea why the ray isnt casted infront of the sprite?