There seems to be an issue with using addObject. When comparing versions, in 0.2.3 the code below adds the player to the same location as p (the spawn point empty) and the player falls gradually (approx) one unit to the ground plane below at the rate of gravity, wheres in 0.2.4 the player object’s xyz values are correct on the first frame (as before) but then the position on the z axis immediately begins to rapidly decrease, pushing the player through the ground plane.
scene = logic.getCurrentScene()
spawn_points = [ob for ob in scene.objects if "player_spawn" in ob]
p = self.select_spawn_point_empty(spawn_points)
spawnObj = scene.objectsInactive["Player"]
player = scene.addObject(spawnObj, p)
Result of the print in 0.2.4 (ground plane wp is at 0,0,0):
<Vector (0.3561, 4.1373, 0.6576)>
<Vector (0.3561, 4.1373, -18.7040)>
<Vector (0.3561, 4.1373, -57.0336)>
<Vector (0.3561, 4.1373, -101.2110)>
<Vector (0.3561, 4.1373, -145.3884)>
<Vector (0.3561, 4.1373, -189.5658)>
<Vector (0.3561, 4.1373, -190.4825)>
<Vector (0.3561, 4.1373, -191.3991)>
<Vector (0.3561, 4.1373, -192.3158)>
<Vector (0.3561, 4.1373, -193.2325)>
<Vector (0.3561, 4.1373, -194.1492)>
The world position of the spawn point empty (when printed out in-game) is the same in both versions. If I raise its position a few units higher there is no change, the spawned object still shoots downwards through the floor.
If I add
player.worldPosition = (0,0,0) to the bottom of the above code then the player is set to the center of the game world (with no initial downward motion other than gravity) and can be controlled as normal. I’ve disabled all other code that would affect the placement of the player, so it looks like this might be an issue with addObject.
All other objects that are libloaded in and then added via addObject (enemies, items) also have the same behavior (i.e. are forced through the floor).
Does anyone else experience this?
Edit: If I adjust the “Fall Speed Max” property to something very low (such as 0.9) then the character floats down to the ground (very) slowly without clipping through the ground, which would suggest that the maximum fall speed is being reached on the first frame.