public static void AddRadialSphereForce(MPWorld world, Vector3 pos, float radius, float strength) { Matrix4x4 mat = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one * radius); MPForceProperties p = new MPForceProperties(); p.shape_type = MPForceShape.Sphere; p.dir_type = MPForceDirection.Radial; p.center = pos; p.strength_near = strength; p.strength_far = 0.0f; p.attenuation_exp = 0.5f; p.range_inner = 0.0f; p.range_outer = radius; world.AddOneTimeAction(() => { MPAPI.mpAddForce(world.GetContext(), ref p, ref mat); }); }
public void MPUpdate() { m_mpprops.dir_type = m_direction_type; m_mpprops.shape_type = m_shape_type; m_mpprops.strength_near = m_strength_near; m_mpprops.strength_far = m_strength_far; m_mpprops.rcp_range = 1.0f / (m_strength_far - m_strength_near); m_mpprops.range_inner = m_range_inner; m_mpprops.range_outer = m_range_outer; m_mpprops.attenuation_exp = m_attenuation_exp; m_mpprops.random_seed = m_random_seed; m_mpprops.random_diffuse = m_random_diffuse; m_mpprops.direction = m_direction; m_mpprops.center = transform.position; m_mpprops.rcp_cellsize = new Vector3(1.0f / m_cellsize.x, 1.0f / m_cellsize.y, 1.0f / m_cellsize.z); Matrix4x4 mat = transform.localToWorldMatrix; EachTargets((w) => { MPAPI.mpAddForce(w.GetContext(), ref m_mpprops, ref mat); }); }