Nope, no difference- using the ref local preserves the original reference rather than copying, so the assignment goes where it needs to.I haven't worked with structs too much, so I'm not entirely sure if there's a difference in this case.
"Rewinding" Simulations
Re: "Rewinding" Simulations
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
I've set the sleep threshold to -1, that has the same effect as manually waking it right?Norbo wrote: ↑Thu Nov 07, 2019 1:39 am Sounds like the object is asleep- many of the BodyReference's functions are intentionally barebones and do not wake the body up automatically. The XML docs for each should mention whether they do or don't. All the direct reference properties and apply impulse functions do not wake the body up. You can set the BodyReference.Awake to true to force the body awake.
I'm almost certain that whatever is going wrong is directly related to how states interact with my flotation system...I don't think it's a Bepu issue.
On the one hand that's good because I don't need to take up any more of your time, but it also means I'm pretty much on my own :/
I guess it's time to sit down and spend a few hours debugging
![Mad :x](./images/smilies/icon_mad.gif)
As always, thanks for all the help and support
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Re: "Rewinding" Simulations
If the body was initialized with a -1 sleep threshold, then yes, it won't go to sleep. Setting the sleep threshold of a sleeping body to -1 won't wake it up, though.I've set the sleep threshold to -1, that has the same effect as manually waking it right?
Good luck!I guess it's time to sit down and spend a few hours debugging
![Very Happy :D](./images/smilies/icon_biggrin.gif)
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
Thanks! I actually managed to figure it out. It was of course something really stupid on my part, namely the state storing a reference to some positions instead of a copy, which ended up screwing up my buoyancy calculations.
Everything seems to be working great now, except for player movement. Jumping works fine, but when it comes to moving horizontally, it's very "stop-and-go" (it stutters a lot). Considering that my buoyancy system—which applies regular impules—works fine when rewinding time, I'm wondering if the stuttering might be due to the character's constraints in some way.
I'm thinking that since it needs more than 1 timestep to accelerate to full speed, it starts to do that, but the next frame comes along during which we don't have the player's input yet, so I assume that the player isn't pressing any keys (might have to change that and predict based on previous inputs). However, I would've thought that when the simulation is rewound and resimulated—this time with all the inputs—this problem of not having time to accelerate would go away (because there's no more timesteps with no keys pressed, so the player shouldn't be "stopping" anymore).
Maybe there's still something wrong on my end, but I thought I'd ask if you've got any idea about what might be going south here.
Re: "Rewinding" Simulations
Is the character state being rewound and replayed properly too? The critical ones would be ViewDirection, TargetVelocity, and TryJump. Other than that, nothing springs to mind.
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
ViewDirection, yes. TargetVelocity and TryJump, nope. I'll take add that tomorrow and see if it fixes it.
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
Alright so I've added TargetVelocity and TryJump to the states, and the stuttering seems to be gone, however the player now moves along the global axes, instead of his local ones (pressing the forward key causes the player to move in the same direction regardless of which way he is facing).
This was not the case before I added TargetVelocity to the state...is there perhaps some kind of conversion I have to do between global and local space? It might just be on my end again though.
This was not the case before I added TargetVelocity to the state...is there perhaps some kind of conversion I have to do between global and local space? It might just be on my end again though.
Re: "Rewinding" Simulations
The TargetVelocity is in terms of the ViewDirection. The ViewDirection is projected onto the support surface to get the forward movement direction, and a TargetVelocity of (0, 1) will move along that projected forward direction. A TargetVelocity of (1,0) will move to the right of that forward direction. So it sounds like there's an inconsistency of some sort in how the ViewDirection and TargetVelocity are being set- a constant ViewDirection, or a TargetVelocity that is accidentally cancelling out the ViewDirection, or something along those lines.
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
So does the order in which I set the two affect anything at all? Is the ViewDirection overriden if I set the TargetVelocity afterwards?
Re: "Rewinding" Simulations
Nope- they're raw fields, no logic is performed on set.
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
So then by "a TargetVelocity that is accidentally cancelling out the ViewDirection" you just mean if I'm setting a TargetVelocity manually, it may not align with the ViewDirection that I've set? That would mean it's on my end again...so probably not an easy fix ![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Re: "Rewinding" Simulations
In the sense that it's not aligned with your actual intent, yup. For example, if your goal is to move along the X axis and so set the ViewDirection to (1,0,0) and the TargetVelocity to (1,0), that would result in the character movement basis 'forward' on a flat plane being (1,0,0), but then the world space target velocity would be (0,0,1) because a TargetVelocity of (1,0) will try to move along the direction to the right of the forward direction.
-
- Posts: 99
- Joined: Wed May 08, 2019 12:17 am
Re: "Rewinding" Simulations
Hmm I see. I guess I'll have to do a bit of digging. Thanks for the helpNorbo wrote: ↑Fri Nov 08, 2019 10:10 pm In the sense that it's not aligned with your actual intent, yup. For example, if your goal is to move along the X axis and so set the ViewDirection to (1,0,0) and the TargetVelocity to (1,0), that would result in the character movement basis 'forward' on a flat plane being (1,0,0), but then the world space target velocity would be (0,0,1) because a TargetVelocity of (1,0) will try to move along the direction to the right of the forward direction.
![Smile :)](./images/smilies/icon_smile.gif)