Save System With Kinematic Controllers
Posted: Thu Dec 28, 2023 7:44 pm
Hey Tony,
So changed the character controller to be a kinematic character controller, and it seems to be conflicting with PositionSaver (i.e. the controller won't let the position be set via the default SetPosition).
I've had a playaround and think I've got a solution but I can't get it to actually work since the PositionSaver script doesn't recognize external namespaces for some reason. Theoretically the below SHOULD work if the PixelCrusher namespace was able to use the KinematicCharacterController namespace (replace the PixelCrusher code setting the navmesh agent/ transform).
I'm not sure why external namespaces (I've tried other namespaces as well) aren't recognized in the PixelCrushers' saver systems (I assume as a safety thing, but I don't really know how that's working). Other scripts are able to pick up and use external namespaces, but let me know if you think it's a local issue.
I THINK that the above would be the "cleanest" solution (assuming it works) since it'd retain the per-scene saving of location etc.
I'm not sure if that's the best way to resolve the problem though; so alternatively, if you could provide boilerplate code to extract the position of an object based on the key -> I could try figure out how to call the Kinematic Set Position from outside the Saver code location as well.
Best Regards,
c
So changed the character controller to be a kinematic character controller, and it seems to be conflicting with PositionSaver (i.e. the controller won't let the position be set via the default SetPosition).
I've had a playaround and think I've got a solution but I can't get it to actually work since the PositionSaver script doesn't recognize external namespaces for some reason. Theoretically the below SHOULD work if the PixelCrusher namespace was able to use the KinematicCharacterController namespace (replace the PixelCrusher code setting the navmesh agent/ transform).
Code: Select all
protected virtual void SetPosition(Vector3 position, Quaternion rotation)
{
player.GetComponent<KinematicCharacterMotor>().SetPositionAndRotation(position, rotation);
}
I THINK that the above would be the "cleanest" solution (assuming it works) since it'd retain the per-scene saving of location etc.
I'm not sure if that's the best way to resolve the problem though; so alternatively, if you could provide boilerplate code to extract the position of an object based on the key -> I could try figure out how to call the Kinematic Set Position from outside the Saver code location as well.
Best Regards,
c