makes_footstep_sound = false,
automatic_rotate = false,
stepheight = 0,
- automatic_face_movement_dir = false,
+ automatic_face_movement_dir = 0.0,
+ ^ automatically set yaw to movement direction; offset in degrees; false to disable
}
Entity definition (register_entity)
drowning, leveled and liquid_range added to ContentFeatures
stepheight and collideWithObjects added to object properties
version, heat and humidity transfer in MapBock
- added new property to entities automatic_face_movement_dir
+ automatic_face_movement_dir and automatic_face_movement_dir_offset
+ added to object properties
*/
#define LATEST_PROTOCOL_VERSION 21
updateNodePos();
}
- if (getParent() == NULL && m_prop.automatic_face_movement_dir){
- m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI;
+ if (getParent() == NULL && m_prop.automatic_face_movement_dir &&
+ (fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)){
+ m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI + m_prop.automatic_face_movement_dir_offset;
updateNodePos();
}
}
m_velocity += dtime * m_acceleration;
}
- if(m_prop.automatic_face_movement_dir){
- m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI;
+ if((m_prop.automatic_face_movement_dir) &&
+ (fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)){
+ m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI + m_prop.automatic_face_movement_dir_offset;
}
}
makes_footstep_sound(false),
automatic_rotate(0),
stepheight(0),
- automatic_face_movement_dir(false)
+ automatic_face_movement_dir(false),
+ automatic_face_movement_dir_offset(0.0)
{
textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255));
writeU8(os, collideWithObjects);
writeF1000(os,stepheight);
writeU8(os, automatic_face_movement_dir);
+ writeF1000(os, automatic_face_movement_dir_offset);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
}
collideWithObjects = readU8(is);
stepheight = readF1000(is);
automatic_face_movement_dir = readU8(is);
+ automatic_face_movement_dir_offset = readF1000(is);
}catch(SerializationError &e){}
}
else
float automatic_rotate;
f32 stepheight;
bool automatic_face_movement_dir;
+ f32 automatic_face_movement_dir_offset;
ObjectProperties();
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
getfloatfield(L, -1, "stepheight", prop->stepheight);
prop->stepheight*=BS;
- getboolfield(L, -1, "automatic_face_movement_dir", prop->automatic_face_movement_dir);
+ lua_getfield(L, -1, "automatic_face_movement_dir");
+ if (lua_isnumber(L, -1)) {
+ prop->automatic_face_movement_dir = true;
+ prop->automatic_face_movement_dir_offset = luaL_checknumber(L, -1);
+ } else if (lua_isboolean(L, -1)) {
+ prop->automatic_face_movement_dir = lua_toboolean(L, -1);
+ prop->automatic_face_movement_dir_offset = 0.0;
+ }
+ lua_pop(L, 1);
}
/******************************************************************************/