forked from tier4/AWSIM
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: fix parenting and script names
also made egoTransform field public in AutowareSimulation.cs Signed-off-by: Alptuğ Cırıt <[email protected]>
- Loading branch information
Showing
5 changed files
with
72 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using UnityEngine; | ||
|
||
|
||
//This script will be improved in the future. Temporarily it will be a bit dirty. | ||
namespace AWSIM | ||
{ | ||
public class HotkeyHandler : MonoBehaviour | ||
{ | ||
private AutowareSimulation _simulation; | ||
private Transform _egoTransform; | ||
private Rigidbody _egoRigidbody; | ||
private Vector3 _initialEgoPosition; | ||
private Quaternion _initialEgoRotation; | ||
|
||
|
||
private void Start() | ||
{ | ||
_egoTransform = gameObject.GetComponent<AutowareSimulation>().egoTransform; | ||
// Store the initial position and rotation of the ego. | ||
_initialEgoPosition = _egoTransform.position; | ||
_initialEgoRotation = _egoTransform.rotation; | ||
// Get the rigidbody of the ego | ||
_egoRigidbody = _egoTransform.GetComponent<Rigidbody>(); | ||
} | ||
|
||
void Update() | ||
{ | ||
// If the escape key is pressed, toggle the GUI panel. | ||
if (Input.GetKeyDown(KeyCode.R)) | ||
{ | ||
ResetEgoToSpawnPoint(); | ||
} | ||
} | ||
|
||
// If the ego transform reference is present, reset the ego to the initial position and rotation. | ||
public void ResetEgoToSpawnPoint() | ||
{ | ||
if (_egoTransform == null) | ||
{ | ||
Debug.LogWarning("Ego transform reference is missing. No ego to reset here!"); | ||
} | ||
else | ||
{ | ||
_egoTransform.SetPositionAndRotation(_initialEgoPosition, _initialEgoRotation); | ||
_egoRigidbody.Sleep(); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.