Missing complete procedure of adding object to the scene with python during runtime

Hi all,

I am working on an RTS game. I have all of my objects organized on layers and I use python scripts to insert them to the visible layer of the scene during runtime.

I will explain my issue with a tree object:
I have few trees on my visible layer before I start the game, so they are visible at the start. When I start the game, I use keyboard to add some more, but the new ones do not have shadow/light rendered when they are added.
Along with that, the biggest issue that I have is that the navigation mesh, which I use for my characters, works for those trees which were placed before game started, but does not work on trees which were added during runtime.

I use scene.addObject(object, object, 0) to add my objects to the scene during runtime. Is there something else I should do for each object so they would have the same effect to the game as the objects which existed before game start?

Thanks in advance

Dynamically added objects are not known before loading the scene. Therefore it is plain impossible to configure them via GUI as this happens before you even start your game session. Therefore you need to change the configuration of your logic bricks after adding the objects.

E.g. you need to reconfigure the steering actuator to use the added navigation object (it is an object … not a mesh). SeeHow to: deal with TrackTo and added Objects - which explains this task at the example of the TrackTo actuator.

My apologies for unclear description :slight_smile:

The problem I had with navigation mesh, characters and trees is because I didn’t check the Create Obstacle option and set the radius on hidden layers as I did before on the main layer… So my bad, I figured out the issue and this part works perfectly now.

What I still didn’t figure out is why the newly added objects do not have shadow from light as the ones which already existed before game start do…

On the image below, you can see a tree in the middle which was placed before the game start (it has shadow). Other trees were added dynamically using keyboard sensors, and they don’t have shadow.

Forgot to mention, I am using Steering actuator with Path following behavior. I forgot to create obstacles in the physics tab for problematic objects :slight_smile:

As far as I remember you need to configure the light/shadow to be applied to the hidden layer too.

Awesome, I selected a light, went to the Object tab, and in Relations section I just switched-on layers which contain my objects.

Thanks Monster :slight_smile: