Reputation: 119
I want to cast a simple Ray
, but if I put my Ray
I want to cast in the Raycast-function Unity keeps insisting on a Vector2
for the origin instead of accepting origin and direction of the ray. So to demonstrate in code:
void Start()
{
RayUp = new Ray2D(transform.position, Vector2.up);
}
void Update()
{
Physics2D.Raycast(RayUp, out WallUp, distance, WallFilter);
Debug.DrawRay(RayUp);
}
Am I missing anything? WallUp, distance and WallFilter are defined
Upvotes: 0
Views: 4403
Reputation: 4333
You are not providing the correct inputs for Debug.DrawRay() and Raycast(). Please take a look at the DrawRay documentation and Raycast() documentation. At a minimum you can do:
Physics2D.Raycast(transform.position, Vector2.up);
Debug.DrawRay(transform.position, Vector2.up);
If you want to maintain consistancy from your original RayUp variable you can do:
Physics2D.Raycast(RayUp.origin, RayUp.direction);
Debug.DrawRay(RayUp.origin, RayUp.direction);
Upvotes: 2