private void OnSceneGUI() { dnp = target as DebugNearestPoint; handleTransform = dnp.transform; handleRotation = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity; SplineLine spline = dnp.spline; Vector3 position = dnp.transform.position; Vector3 nearestPoint = spline.GetNearestPointOnSpline(position); //Vector3 nearestPoint = spline.GetNextControlPoint(0); Debug.Log(nearestPoint.ToString()); float size = HandleUtility.GetHandleSize(position); //spline.transform.TransformPoint(nearestPoint) Handles.DrawLine(nearestPoint, position); Handles.Button(nearestPoint, Quaternion.identity, size * handleSize, size * pickSize, Handles.DotHandleCap); }
public override void Interaction(ObjectInteractionController oicCaller, Collider other) { if (other.tag == Tags.player) { SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>(); bool isHidden = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.HIDDEN]; if (!isHidden) { otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, true); otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true); deskProgress = deskSpline.GetNearestProgressOnSpline(otherPcc.transform.position); //otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position), // Quaternion.Euler(deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized))); SoundManager.GetAudio(audioTPID).Play(); GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation); float dotMagnitude = Vector3.Dot(otherPcc.transform.forward, Camera.main.transform.right); //Debug.Log("dotMagnitude:" + dotMagnitude); otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position), Quaternion.LookRotation(dotMagnitude * deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), Vector3.up)); } else { otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false); otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, false); otherPcc.progress = otherPcc.lSpline.GetNearestProgressOnSpline(otherPcc.transform.position); SoundManager.GetAudio(audioTPID).Play(); GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation); otherPcc.Move(otherPcc.transform.forward); } } }