davidlallen
Deity
I am using pUnit.convert() to convert one unit into a different unit type. The code is:
pNew = pOwner.initUnit(iType, pOld.getX(), pOld.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_EAST)
pNew.convert(pOld)
pOld.kill(true, iOwner)
It is working. But, notice "EAST". If the unit was facing some other direction, it suddenly spins to face east. This is not fatal, but undesirable.
Is there a way to get the DirectionTypes of a unit, and then set it? There is nothing I can immediately find in the python API which seems relevant. There is CvUnitEntity.getUnitFacingDirection, but it returns a float, and I don't know the relationship between CvUnit and CvUnitEntity. For example, there is no CvUnit.getEntity or similar.
Can anybody suggest how to convert without changing direction?
pNew = pOwner.initUnit(iType, pOld.getX(), pOld.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_EAST)
pNew.convert(pOld)
pOld.kill(true, iOwner)
It is working. But, notice "EAST". If the unit was facing some other direction, it suddenly spins to face east. This is not fatal, but undesirable.
Is there a way to get the DirectionTypes of a unit, and then set it? There is nothing I can immediately find in the python API which seems relevant. There is CvUnitEntity.getUnitFacingDirection, but it returns a float, and I don't know the relationship between CvUnit and CvUnitEntity. For example, there is no CvUnit.getEntity or similar.
Can anybody suggest how to convert without changing direction?