protected override bool ShouldStop() { //NUEVO PUNTO PARA EL LLAMADO DE LA COLISION, PARA NO DEPENDER DEL CHECK DEL ENTITY CONTROLLER// bool stop = false; RaycastCheckResult collisionCheck = HasCollided(); if (collisionCheck.collided && collisionCheck.otherEntity.IsOnTheStreet) { stop = true; DebugController.LogErrorMessage("Player should stop!"); OnEntityCollision(collisionCheck.otherEntity); } return stop; // return input.IsBraking; }
/// <summary> /// Checks using a raycast if there is a obstacle in front of the entity. /// </summary> /// <returns></returns> private bool IsThereAObstacle() { bool obstacle = false; RaycastCheckResult obstacleCheckResult = default; if (aiEntity.IsOnTheStreet) { obstacleCheckResult = aiEntity.HasAObstacleUpFront(); if (obstacleCheckResult.collided && obstacleCheckResult.otherEntity.IsOnTheStreet) { obstacle = true; } } return(obstacle); }
/// <summary> /// Checks for a obstacle ahead.true If it's a pedestrian or car stops. /// </summary> /// <returns>True if there is a obstacle ahead. False if not.</returns> public RaycastCheckResult CheckForCollision(Vector3 _direction, Vector3 _startPosition, Vector3 _axis, float _distance, float _checkWidth) { RaycastCheckResult result = new RaycastCheckResult(); GameObject obstacle = PhysicsHelper.RaycastOverALineForFirstGameObject(gameObject, _startPosition, _axis, _checkWidth, _direction, _distance, layersToCheckCollision, 5); if (obstacle) { if (obstacle.CompareTag("Pedestrian") || obstacle.CompareTag("Car")) { result.otherEntity = obstacle.GetComponent <EntityController>(); result.collided = true; } } return(result); }
private void Update() { if (DebugController.debugActive) { if (speedText) { speedText.text = aiToDebug.GetMovableComponent.GetCurrentSpeed.ToString(); } if (currentState) { currentState.text = aiToDebug.GetCurrentState.ToString(); } if (canCross) { canCross.text = "Cross: " + aiToDebug.GetCurrentCrossingZone?.CanCross(aiToDebug).ToString(); } if (onTheStreet) { onTheStreet.text = "Street: " + aiToDebug.IsOnTheStreet.ToString(); } if (currentDirection) { currentDirection.text = "Direction: " + aiToDebug.GetCurrentDirection.ToString(); } if (obstacle) { // if (!aiToDebug.IsCrossingCrosswalk) // { // RaycastCheckResult obstacleResult = aiToDebug.CheckForObstacles(); // obstacle.text = "Obstacle: " + (obstacleResult.collided && obstacleResult.otherEntity.IsOnTheStreet).ToString(); // } RaycastCheckResult obstacleResult = aiToDebug.CheckForObstacles(); obstacle.text = "Obstacle: " + (obstacleResult.collided && obstacleResult.otherEntity.IsOnTheStreet).ToString(); } } }