When the script runs, the Debug.Log("Ray drawn") line works, but no ray is drawn. I have already tried changing color, distance, and the position of both the object and the ray. It doesn't show. Any ideas?
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackCheck : MonoBehaviour
{
public bool hitting = false;
Rigidbody2D rb;
void Start()
{
hitting = false;
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.forward, 1000f);
Debug.Log("Ray drawn");
Debug.DrawRay(transform.position, transform.forward, Color.blue, 50f);
}
}
Try to replace the line of code:
with:
The time that you set has no sense because you are drawing the ray at runtime, so it is not required to keep it alive for more than one frame.
If it doesn't still work try to enable gizmos while in play mode, press the gizmos button on the top right corner of the screen, and you should be able to see it.