Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controllable NPC Vehicle feature #378

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

szylis
Copy link
Contributor

@szylis szylis commented Dec 21, 2024

The ControllableNPC feature allows the user to control a NPC vehicle, when EGO is in Autonomous mode. The user can set the type of NPC vehicle to control and the spawn location of this vehicle.

Info about this new type of vehicle

ControllableNPCVehicle is a non-EGO vehicle that can be controlled by the user. To simplify the design and reuse some ready-made scripts, this type of vehicle uses some functionality of the EGO vehicle. Therefore, the prefab composition and included components are similar to the EGO vehicle.

However, Controllable NPC vehicle does not contain any sensors and it does not support autonomous mode.

This PR adds:

Prefabs:

  • ControllableNPCVehicleManager.prefab
  • ControllableNPCVehicleUI.prefab
  • and prefabs of controllable NPC Vehicles, which are under this path: Assets/AWSIM/Prefabs/ControllableNPCs/Vehicles/*

Components:

  • ControllableNPCVehicleManager - handles all elements required by the controllable NPC vehicle, including spawning the selected vehicle, and initializing its camera view. Additionally, it serves as an intermediary between the vehicle object and the ControllableNPCVehicleUI, facilitating tasks such as retrieving collision information and passing it to the UI view.
  • ControllableNPCVehicleUI - displays the UI for controllable NPC vehicle, such as top-down camera view, info about current speed and gear shift, info about collisions and dropdown menu to select the input device.
  • ControllableNPCVehicleOverrideInputManager - input manager designed for this type of vehicle. It supports only manual input.
  • ControllableNPCVehicleCollisionDetector - used to detect when the controllable vehicle collides with other specified objects.
  • ControllableNPCVehicleCamera - used to handle the camera view of controllable NPC vehicle.

Implemented changes to existing code

  • adding new collision layer for ControllableNPCVehicle, this new layer is named ControllableNPC
  • removal of [RequireComponent(typeof(VehicleOverrideInputManager))] attribute from VehicleInputBase class. This attribute is typically employed to ensure a specific setup and to prevent setup errors, however I believe in this case, it's not necessary. Because the VehicleInputBase does not actually depend on the VehicleOverrideInputManager. Removing this attribute allows me to use already existing input components (like the VehicleKeyboardInput), together with the ControllableNPCOverrideInputManager. The ControllableNPCOverrideInputManager is dedicated input manager for ControllableNPC Vehicle.
  • adding an option to disable manual input for VehicleOverrideInputManager. This allows it to keep EGO in autonomous mode when ControllableNPC Vehicles are used.

@szylis szylis requested a review from mackierx111 December 21, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant