I have a reference to a XR character’s dynamic move provider in my script.
I now want to change the MoveSpeed of the move provider so the XR player can run or walk.
But setting MoveSpeed through script seems to have no effect in the game. How can I fix this?
public class PlayerScript : MonoBehaviour {
public DynamicMoveProvider dynamicMoveProvider;
private bool running = true;
void Update(){
if(running){
dynamicMoveProvider.moveSpeed = 3f;
} else {
dynamicMoveProvider.moveSpeed = 1.4f;
}
}
}
Is this PlayerScript attached to an object in your scene? Can you send me a screenshot of what that looks like in the inspector?
Is the DynamicMoveProvider assigned in the inspector on your PlayerScript?
Do you have any errors in your console log when running in play mode?
Is the screenshot of the move provider you have during play mode or during edit mode?
Additionally, we have VERY similar logic in our VR Multiplayer Template (where we are setting the move providers move speed). Feel free to make new project based on that template if the above questions don’t help!
Hey , I found a fix , Hope this helps other people in the future
public class PlayerScript : MonoBehaviour {
//public DynamicMoveProvider dynamicMoveProvider;
[SerializeField] private ContinuousMoveProviderBase dynamicMoveProvider;
//Replace DynamicMoveProvider type with this one and it will work!
private bool running = true;
void Update(){
if(running){
dynamicMoveProvider.moveSpeed = 3f;
} else {
dynamicMoveProvider.moveSpeed = 1.4f;
}
}
}