private void DrawTrack(GameObject drawOnly) { if (m_track == null || m_track.childCount < 2) { return; } for (int i = 0; i < m_track.childCount - 1; i++) { var child1 = m_track.GetChild(i); var platform1 = child1.GetComponent <PlatformJumpPointView>(); var child2 = m_track.GetChild(i + 1); var platform2 = child2.GetComponent <PlatformJumpPointView>(); if (drawOnly != null && drawOnly != child1.gameObject && drawOnly != child2.gameObject) { continue; } Vector3 jumpPoint; float jumpTraDist = JumpResolver.GetOptimalJumpTrajectoryDistance( platform1.Position, platform1.GetJumpSpeed(), platform1.GetJumpAngle(), 8.0f, Mathf.PI / 4, platform2.Position, out jumpPoint); DrawJumpTrajectory( platform1.Position, platform1.GetDirection2D(), platform1.GetJumpAngle(), platform1.GetJumpSpeed(), Color.green, jumpTraDist); var targetDist = platform2.Position - jumpPoint; targetDist.y = 0.0f; DrawJumpTrajectory( jumpPoint, platform1.GetDirection2D(), Mathf.PI / 4, 8.0f, Color.yellow, targetDist.magnitude); //Gizmos.color = Color.yellow; //Gizmos.DrawSphere(jumpPoint, 0.2f); } }
private void UpdatePlatformOptimalJumpDistances() { if (transform.childCount < 2) { return; } for (int i = 0; i < transform.childCount - 1; i++) { var child = transform.GetChild(i).GetComponent <PlatformJumpPointView>(); var childNext = transform.GetChild(i + 1).GetComponent <PlatformJumpPointView>(); Vector3 jumpPosition; child.AirJumpOnDistance = JumpResolver.GetOptimalJumpTrajectoryDistance( child.NativePosition, child.GetJumpSpeed(), child.GetJumpAngle(), 8.0f, Mathf.PI / 4.0f, childNext.NativePosition, out jumpPosition); } }