jMonkey SDK SceneComposer Stop / Reset Physics

I am having an issue with the controls. Once the controls are started, they never stop. For example, I have a character control and when I stop all, on the scene, or even object, it doesn’t stop. I then am unable to move the object around as it keeps resetting the position. Am I running into a bug or is this expected behavior?

1 Like

I think you can use SS editor to work with physics :wink:

1 Like

Are you setting the position on the physics control?

Edit: there is also a method on the physics control called something like applyLocal(boolean) that updates the local translation from the physics location.

1 Like

What behavior do you expect? When you stop the Physics the objects indeed are frozen.
Especially when using jme you need to set the physical position since it Updates the spatials position to that. Even when using third party Editors :slight_smile:

1 Like

The expected behavior is that when the control is stopped, it returns to the original state before it was played.

With the character control, once its added to the spatial, you can no longer move the spatial. You have to move the character control, but the SDK does not allow moving the controls through the viewport, and I have to type in the physical location through the properties panel.

1 Like

Yeah, that’s exactly what would happen to you in a game, though.
The reason is: When moving parts around in the SceneComposer it attempts to change the localTranslation. This however doesn’t work anymore when there is a characterControl, so for this to work you’d have to remove the CharacterControl.

What might be a bug in the engine or sdk is that a stopped control shouldn’t overwrite the localTranslation so you should be able to move the character but it should snap back to the old (physics) position once you press play again.

No, a physics control will always apply the physics location to the spatial, even when the physics object isn’t moving (through physics or otherwise). That happens in the opngl update loop and has nothing to do with the physics running or not.

As for moving spatials with a physics control, the SDK should actually allow you to move it using the movement widgets as they check for a physics control first. But as you said, changing the localTranslation directly won’t work for the mentioned reasons.

1 Like

Here is a quick video, this may be specific to the built-in character control, as I can move other spatials just fine.
Unable to move spatial once character control is added

1 Like

Sure but stopping a control should essentially call setEnabled(false) which should lead to the update loop not being called. However I guess CharacterControl is not built on top of AbstractControl but implements Control.

@sutabi Does it work with the BetterCharacterControl?

1 Like

Not really, since setEnabled was removed from generic Controls its not really in wide-spread use in the engine. But sure, it could be used instead.

1 Like

Well adding the custom control resulted in a “NULL” exception and doesn’t appear in the SceneExplorer. I tried several times and ended up saving and closing the scene. Once I reopened it, it had several instances of the control. So I delete all but one. The control was added, just not sure why it was tossing in null exceptions.

Once it was showing up, I then tried to move the spatial, but was not able too. I needed to uncheck “Enabled”. I can move the spatial once its unckeched. But as soon as I check it, it moves back to the 0,0,0 position and there are no properties to set the start position of this control.

Its odd that the BetterCharacterControl extends AbstractPhysicsControl but the getter/setter methods are not showing up from the PhysicsControls.

Overall I am guessing its the control thats the issue. I am guessing this is an easy fix, but then why are the other physic controls now appears for the BetterCharacterControl?

1 Like

I dont understand this question actually.

Which exactly is the expected behavior, since the translation is only the visual representation and is set to where the object physically is.

This is related to the BCC, it does not expose the internal parameters actually.

So I see it’s a bit cumbersome but the control should set the physics location to the translation if you are starting it for the first time per game-session, so it’s probably the best to set this value once you are satisfied with the position of you character, I don’t know.

1 Like