Tag: no 51cto
Sometimes you need to check the scene in the project.
There are two points in this, and the calculation of the dash and front of the character
Dash with Lineranderer
The character is right in front of
Go.transform.forward + go.transform.position
The coordinates of the characters plus the forward direction of the characters.
(When I first hardheaded thinking of the front of the Go.transform.forward is not the front of the character, but if not add their own coordinates, it is only a direction, that is, this coordinate is only relative to the origin of the direction, plus coordinates is the point you want)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class DrawLine : MonoBehaviour { public LineRenderer line; public GameObject go; // Use this for initialization void Start () { } void Update() { Vector3 targetPos = go.transform.forward + go.transform.position; line.SetPosition(0, go.transform.position); line.SetPosition(1, targetPos); } }
If it's just debug, there's an easier way.
Debug.DrawRay()Debug.DrawLine()
"Komatsu teaches you to swim and develop" unity practical skills draw a line before Gameobject