Unity debug drawray не работает

Debug.DrawRay

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Declaration

Parameters

start Point in world space where the ray should start.
dir Direction and length of the ray.
color Color of the drawn line.
duration How long the line will be visible for (in seconds).
depthTest Should the line be obscured by other objects closer to the camera?

Description

Draws a line from start to start + dir in world coordinates.

The duration parameter determines how long the line will be visible after the frame it is drawn. If duration is 0 (the default) then the line is rendered 1 frame.

If depthTest is set to true then the line will be obscured by other objects in the Scene that are nearer to the camera.

The line will be drawn in the Scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2021 Unity Technologies. Publication Date: 2021-10-08.

Источник

Debug.DrawRay

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста попробуйте снова через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Параметры

start @param start Точка в мировом пространстве, откуда начнётся луч.
dir @param dir Направление и длина луча.
color @param color Цвет отображаемой линии.
duration @param duration Время отображения линии (в секундах).
depthTest @param depthTest Будет ли линия перекрываться более близкими к камере объетами?
Читайте также:  Как настроить мышь под левшу

Описание

Рисует линию от точки start до точки start + dir в мировых координатах.

duration — сколько (в секундах) линия будет отображаться. При duration равное 0 (по умолчанию) линия будет отображаться один кадр.

Если depthTest установлен в «true», то линия будет перекрываться более близкими к камере объектами.

Линия будет нарисована в редакторе в окне сцены (Scene View). Если в окне игры (Game View) включено отображение гизмо, то линия также будет отображаться и в этом окне.

Источник

Debug.DrawRay

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Parameters

start Point in world space where the ray should start.
dir Direction and length of the ray.
color Color of the drawn line.
duration How long the line will be visible for (in seconds).
depthTest Should the line be obscured by other objects closer to the camera?

Description

Draws a line from start to start + dir in world coordinates.

The duration parameter determines how long the line will be visible after the frame it is drawn. If duration is 0 (the default) then the line is rendered 1 frame.

If depthTest is set to true then the line will be obscured by other objects in the Scene that are nearer to the camera.

The line will be drawn in the Scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there.

Did you find this page useful? Please give it a rating:

Thanks for rating this page!

What kind of problem would you like to report?

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at

Thanks for letting us know! This page has been marked for review based on your feedback.

Читайте также:  Что нужно делать если у тебя не работает клавиатура

If you have time, you can provide more information to help us fix the problem faster.

You’ve told us this page needs code samples. If you’d like to help us further, you could provide a code sample, or tell us about what kind of code sample you’d like to see:

You’ve told us there are code samples on this page which don’t work. If you know how to fix it, or have something better we could use instead, please let us know:

You’ve told us there is information missing from this page. Please tell us more about what’s missing:

You’ve told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

You’ve told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

You’ve told us there is a spelling or grammar error on this page. Please tell us what’s wrong:

You’ve told us this page has a problem. Please tell us more about what’s wrong:

Thanks for helping to make the Unity documentation better!

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright © 2018 Unity Technologies. Publication: 2018.2-002P. Built: 2019-01-17.

Источник

Why the raycast is not drawn using Debug.DrawRay?

I don’t see the ray drawn anywhere when running the game in the scene view window.

I found the problem when shooting the raycast from the hand the hand rotation seems to be wrong or maybe it’s in the script. When I’m running the game the yellow raycast is pointing directly up and when the hand pointing a target the yellow direction is back and up directions that’s why it’s never red :

The hand part I’m trying to shoot raycast from is child of a child of the player.

I added an empty GameObject position and rotation set to 0,0,0 and now it’s shooting the raycast to the opposite direction not sure why :

The full script :

1 Answer 1

There are a few things to fix:

  • hand.transform.TransformDirection(Vector3.forward) is pointlessly complicated. Use hand.transform.forward .
  • You haven’t specified a duration for the line, so it will only last 1 frame. Here I use a duration of 5 seconds to ensure that you don’t miss it. You’ll want to remove that part once you figure out what’s wrong, or you’ll have red lines all over the place.
  • Sometimes lines aren’t visible because the line is too short. I multiply the length by 10 to hopefully make the line visible.
  • Log a message to the console when the raycast hits, so we know whether the line is getting drawn at all.
  • As suggested by DMGregory, draw a different color line when the raycast is not hitting (I chose blue) so we know where the hand is pointed at all times.
Читайте также:  Как определить что датчик расхода воздуха не работает

I don’t understand what you are saying about the yellow line. You should probably share the code that you’re using to draw the yellow line.

Источник

Debug.DrawRay

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Parameters

start Point in world space where the ray should start.
dir Direction and length of the ray.
color Color of the drawn line.
duration How long the line will be visible for (in seconds).
depthTest Should the line be obscured by other objects closer to the camera?

Description

Draws a line from start to start + dir in world coordinates.

The duration parameter determines how long the line will be visible after the frame it is drawn. If duration is 0 (the default) then the line is rendered 1 frame.

If depthTest is set to true then the line will be obscured by other objects in the scene that are nearer to the camera.

The line will be drawn in the scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there.

Did you find this page useful? Please give it a rating:

Источник

Оцените статью