- Home /
Physics2D.Raycasting questions
Having a problem understanding, and setting up raycast for a 2D project. Right now im currently trying to set it up to where I draw the ray with debug.drawline and want it to give me a message of hitting target when the ray hits a other collider. After that I wanna implement a rough shooting mechanic.
my current code
using UnityEngine; using System.Collections; public class Control : MonoBehaviour { // Update is called once per frame void Update () { Physics2D.Raycast (transform.position, Vector2.up, 25f); Debug.DrawLine (transform.position, Vector2.up, Color.red); } }
couple of questions are is transform.position ok for the orgin. Do vector 2 work for it or do I have to use vector3, Im not using layermasking so do I have to add that into my parameters. what wil be the more effiect way to draw the line?
sorry If im asking such noob questions but I wanna understand this completely because I see how important it is understanding code in video game development.
Your answer
Follow this Question
Related Questions
Raycast2D Layermasks and incomplete docs 1 Answer
Raycast2D always "remembers" it's last hit 2 Answers
Raycasting in 2D is not working 0 Answers
Inaccurate Touch Detection iOS 1 Answer