// Update is called once per frame public void AddObject(Transform parent) { float spacing = SpacingCoef + Random.Range(0, 1f); float length = 1 + StretchCoef * Random.Range(0, 1f); float r = Random.Range(-20f, 20f); float rz = spacing * Random.Range(0f, 1f); SplineLine sl = Instantiate(ss, lastPosition.withY(lastPosition.y - rz), Quaternion.Euler(0f, (360f / 4f) * (count % 4) + r, 0f), parent).GetComponent <SplineLine>(); sl.gameObject.SetActive(true); sl.gameObject.name = "Spline"; lastPosition = sl.Init(100, length); count++; //every 8 lines, we add a platform, if (count % 5 == 4 && rz > 4f) { GameObject pl = Instantiate(platform, sl.endPos.withY(sl.endPos.y + 2f * spacing), Quaternion.identity, sl.gameObject.transform); SplineLine sls = Instantiate(ss, sl.endPos, Quaternion.identity, pl.transform).GetComponent <SplineLine>(); Vector3[] splineTargets = new Vector3[3]; splineTargets[0] = sl.attachPos; splineTargets[1] = 0.5f * (sl.attachPos + pl.transform.position) + 3f * length * sl.transform.forward; splineTargets[2] = pl.transform.position; sls.InitSimple(splineTargets); sls.line.widthMultiplier *= 0.5f; sls.gameObject.SetActive(true); pl.SetActive(true); } if (count % 30 == 0) { Debug.Log(sl.endPos.y / Mathf.Floor(count / 30)); } }
private void LevelSetupDoor(ref GameData gdd) { GameObject player = GameObject.FindGameObjectWithTag(Tags.player); SplinePlayerCharacterController spcc = player.GetComponent <SplinePlayerCharacterController>(); SetUpSPCC(spcc, ref gdd); if (spcc != null) { SplineLine spline = spcc.lSpline; GameObject[] resGOList = GameObject.FindGameObjectsWithTag(Tags.respawn); foreach (GameObject go in resGOList) { ToiletInteractionController tIntCont = go.GetComponent <ToiletInteractionController>(); if (tIntCont != null) { if (tIntCont.toiletNum == gdd.toiletNum) { PositionPlayer(tIntCont.transform, spcc); SplineCameraController mCC = Camera.main.GetComponent <SplineCameraController>(); if (mCC != null) { mCC.currCameraPos = tIntCont.nextCameraPosition; } } } } } gdd = null; }
// Update is called once per frame public void AddObject(Transform parent) { float spacing = SpacingCoef + Random.Range(0, 1f); float length = 1 + StretchCoef * Random.Range(0, 1f); float r = Random.Range(-20f, 20f); float rz = spacing * Random.Range(0f, 1f); SplineLine sl = Instantiate(ss, lastPosition.withY(lastPosition.y - rz), Quaternion.Euler(0f, (360f / 4f) * (count % 4) + r, 0f), parent).GetComponent <SplineLine>(); sl.gameObject.SetActive(true); sl.gameObject.name = "Spline"; lastPosition = sl.Init(100, length); count++; //every 8 lines, we add a platform, if (count % 5 == 4 && rz > 2f) { Vector3 endPos = sl.attachPos; Quaternion lookRot = Quaternion.LookRotation(endPos.withY(0).withX(endPos.x + Random.Range(-5, 5f)).normalized); endPos = endPos.withY(endPos.y - 3.6f); GameObject pl = Instantiate(platform, endPos, lookRot, sl.gameObject.transform); pl.SetActive(true); } if (count % 30 == 0) { Debug.Log(sl.attachPos.y / Mathf.Floor(count / 30)); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); dnp = target as DebugNearestPoint; SplineLine spline = dnp.spline; Vector3 position = dnp.transform.position; DrawDebug("Nearest Progress :", spline.GetNearestProgressOnSpline(position).ToString()); }
private void DrawSplineLine(string name, ref SplineLine property) { EditorGUI.BeginChangeCheck(); SplineLine propertyTemp = (SplineLine)EditorGUILayout.ObjectField(name, property, typeof(SplineLine)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(instanMod, name + " change"); EditorUtility.SetDirty(instanMod); property = propertyTemp; } }
protected void ArrivedAtDestination(AI_BehaviorBrain brain) { NavMeshAgent agent = brain.navMeshAgent; AI_PatrolData patrolData = brain.GetComponent <AI_PatrolData>(); ptrSplineLine = patrolData.ptrSplineLine; if (agent != null && ptrSplineLine != null) { BeforeChangingDestination(brain); patrolData.currentPreviousSplinePoint = ptrSplineLine.GetNextControlPointIndex(patrolData.currentPreviousSplinePoint); AfterChangingDestination(brain); } }
public override void OnInspectorGUI() { //DrawDefaultInspector(); spline = target as SplineLine; DrawLoopToggle(); DrawTSelector(); DrawDistSelector(); if (selectedIndex >= 0 && selectedIndex < spline.GetControlPointCount) { DrawSelectedPointInspector(); } EditorGUILayout.BeginHorizontal(); DrawAddCurveButton(); DrawRemoveCurveButton(); EditorGUILayout.EndHorizontal(); }
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); }
protected void Patrol(AI_BehaviorBrain brain) { NavMeshAgent agent = brain.navMeshAgent; AI_PatrolData patrolData = brain.GetComponent <AI_PatrolData>(); ptrSplineLine = patrolData.ptrSplineLine; if (agent != null && ptrSplineLine != null) { currentPreviousSplinePoint = patrolData.currentPreviousSplinePoint; agent.destination = ptrSplineLine.transform.TransformPoint(ptrSplineLine.GetNextControlPoint(currentPreviousSplinePoint)); agent.isStopped = false; agent.stoppingDistance = stopDist; if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending) { //int pointCnt = ptrSplineLine.GetControlPointCount; //int nextPointIndex = ptrSplineLine.GetNextControlPointIndex(currentPreviousSplinePoint); ArrivedAtDestination(brain); } } }
private void OnSceneGUI() { spline = target as SplineLine; int length = spline.GetControlPointCount; Vector3[] points = new Vector3[length]; handleTransform = spline.transform; handleRotation = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity; for (int i = 0; i < length; i++) { points[i] = ShowPoint(i); if (i + 1 != length) { Handles.DrawLine(handleTransform.TransformPoint(spline.GetControlPoint(i)), handleTransform.TransformPoint(spline.GetControlPoint(i + 1))); } } Handles.color = Color.red; float size = HandleUtility.GetHandleSize(points[0]); Handles.Button(spline.GetPoint(spline.t), Quaternion.identity, size * handleSize, size * pickSize, Handles.DotHandleCap); // Debug.Log("Length :" + spline.GetLength(spline.t) + "Param : "+ spline.GetParametricLength(spline.GetLength(spline.t))); }