Page 1 of 1

Spawning an item on inclined terrain?

Posted: Sun Nov 30, 2014 11:35 am
by Ixnatifual
I have a script that spawns an items in a terrain area affected by a heightmap. Unfortunately this means the item isn't very visible because it's partially "buried" into the incline. Only when walking into the square does the item pop out of the terrain.

Anyone found a clever general method to make items "float up" when spawning them on heightmapped terrain through a script?

Re: Spawning an item on inclined terrain?

Posted: Wed Dec 03, 2014 9:08 pm
by Ixnatifual
I attempted to do it by spawning the item in the air, hoping it would then drop down to the ground on top of the incline instead of inside it.

Code: Select all

spawnedItem:setPosition(entity.x, entity.y, entity.facing, entity:getElevation() + 1, entity.level
Doesn't help, though. The item is still halfway buried in the ground... or completely buried if it's a small item. My current workaround is to only allow the item to spawn on flattened squares in the area.

Re: Spawning an item on inclined terrain?

Posted: Wed Dec 03, 2014 10:35 pm
by Batty
Did you try GameObject:setWorldPositionY(y)? You can make small intratile adjusments with it.

Something like rock_1:setWorldPositionY(.08) might do it. Although, it may popup above ground when you step on the tile...