Detect the maximum level of the trick the player can safely perform before landing. The time will be calculated supposing the trick is performed at normal speed (no link or pefect link).
System
- Detect the time until landing. This is done as soon as the player leaves the ground.
- Check against the time for every trick level.
- Show a gizmo on the UI with the color of the corresponding trick level.
Detecting the landing time
int GetLandingTime(){
bool landingSpotFound = false;
float distX = 0f, distY = 0f;
float safetyDistance = 10f;
float ySpeed = currentJumpSpeed;
int landingTime = 0;
//RaycastHit landingSpotInfo = new RaycastHit();
while (!landingSpotFound){
origin = new Vector3(transform.position.x + distX, transform.position.y + safetyDistance, transform.position.z);
if (RaycastHit(origin, Vector3.Down, out landingSpotInfo, safetyDistance + distY, layerTerain)){
landingSpotFound = true;
}else{
distX += currentSpeed;
distY += ySpeed;
ySpeed += gravity;
landingTime++;
}
}
return landingTime;
}
No hay comentarios:
Publicar un comentario