Jump to content

Node updates only if far away?


photo

Recommended Posts

Hello,

 

root = new NodeDummy();

actor = new PlayerActor();
controls = new ControlsDummy();
smesh = node_load("nodes/smesh.node");


actor.setControls(controls);
actor.setParent(root);
smesh.setParent(actor);

controls.setState(CONTROLS_STATE_FORWARD, 1);

engine.world.addUpdateNode(root);
engine.world.addUpdateNode(actor);
engine.world.addUpdateNode(smesh);

 

Expected Behavior:

The mesh appears @ origin, behaves physically (in this case falling to the ground), and moves forward.

 

Actual Behavior: (view with editor loaded)

The mesh does not appear. The PlayerActor's bounding capsule is visible, and appears @ origin, and falls physically to the ground, but does not move forward.

 

However, if you move the editor camera far enough away from the visible capsule, the mesh appears and starts to move forward.

 

Any ideas what's going on?

 

 

 

Michael Zhang

Link to comment

Was hoping it was something simple, like I was using addUpdateNode or some setting was wrong.

 

Well, here's the simple test case attached.

It should work simply by placing them in the data/demos/ folder and loading up the world.

world_load demos/controls_test

 

Make sure to turn on editor and Show Physics Shapes.

 

I noticed while making this simple test case, that the problem does not occur if the camera spawns @ origin.

Rather, the camera must be spawned below the origin. While the physics correctly updates (it falls). The controls, seem to be frozen since it's not in view initially, but it doesn't unfreeze when it falls into view..

I'd like to the controls to always update.

demos.zip

Link to comment

Actually, this seems to be related to a more general issue:

 

PlayerActor does not update its behavior based upon Controls unless the PlayerActor is in the view frustum.

 

Adding actor to world update nodes does not seem to fix this because that only causes PlayerActor to always update physically. But the behavior of PlayerActor is not being updated based upon the updated Controls.

 

So, when I look at the Player, tell him to move forward, then look away, and stop moving forward.. he continues to move forward while I'm not looking. As soon as I look at the player, the PlayerActor's behavior is updated by the Controls, and stops moving.

 

The test case provided here is a very special case scenario, in which the PlayerActor spawns above the camera. Then, it falls into view. Interestingly, it does not detect the PlayerActor as being "in view" when it falls into view until you move far enough away!

 

I'd love to get this fixed ASAP!

 

 

 

 

Michael Zhang

Link to comment

Aha! Easy enough fix :) Thank you. I knew I was doing something wrong.

 

Seems like that function should be called "updateNode", since it only does it once. addUpdateNode sounds like it is being added to a list of nodes that will be updated regularly. Oh well, probably too late to change the name now. But, you should definitely update the documentation to clearly specify that it needs to be called every update.

Link to comment
×
×
  • Create New...