Hi, I want to use ray perception sensor component. I attach it to my agent gameobject, it works but it also affected by agent’s rotation which I don’t want. How to create constant rays without affecting the agent’s rotation?
I solved it by;
- Create a new empty child gameobject.
- Attach this a new script that responsable for fixing the rotation.
- Add the ray perception sensor to this child gameobject.
Unfortunately, I don’t have a better solution than that currently. We can think about adding a more general solution for this in the future.
Just curious, what’s the use case for this?
I used it on a 2.5D platformer game where the characters are rotate when they move.
this doesnt work for me. i am updating the rotation in Update() with this.transform.rotation = Quaternion.identity;
however when using e.g. --time-scale 100 the update doesnt sync up properly with the sensor raycasts
and its just a simple ball that is rolling about that i want a raycast sensor for to detect the ground/objects etc
Hi, the script attached to this gameobject is;
private Quaternion _initialRotation;
private void Awake(){
_initialRotation = transform.rotation;
}
private void Update(){
transform.rotation = _initialRotation;
}
hey. as i said rotation in Update() does not work properly when increasing the time scale if the sensor is attache. I also added these lines to FixedUpdate() and LateUpdate() but still the same problem. to solve this problem I ended up changing the hierarchy of my agent so that the Agent component was on the parent object with DecisionRequestor and BehaviorParameters, the actual rotating ball was a separate child game object with no ml-agent components attached, the sensor was again another separate child game object with the sensor attached. this way the sensor never gets rotated but it will still get its position moved so i aligned it with this.transform.position = ball.transform.position; instead.