public override void FixedUpdate(float fixedDeltaTime) { var position = StreamerManager.GetTilePosition(m_Position.x, m_Position.y, m_Position.z); m_Velocity += Physics.gravity * Time.fixedDeltaTime; var deltaPos = m_Velocity * Time.fixedDeltaTime; m_Position += deltaPos; m_TotalDis += deltaPos; if (m_BulletEntity != null) { m_BulletEntity.SetPosition(m_Position); m_BulletEntity.gameObject.transform.localScale = Vector3.one * m_TotalDis.magnitude * m_DisFactor; } RaycastHit hit; if (Physics.Raycast(position, deltaPos.normalized, out hit, deltaPos.magnitude, LayerConfig.BulletMask)) { if (onBulletHit != null) { onBulletHit(hit); } } }
public void VerifyLandedPos() { if (isClientVerify) { return; } Vector3 tilePos = StreamerManager.GetTilePosition(currentPos); RaycastHit hit; if (PhysicsUtility.Raycast(tilePos, Vector3.down, height, LayerConfig.ParachuteMask, out hit)) { isClientVerify = true; Vector3 hitRealpos = StreamerManager.GetRealPosition(hit.point); height = serverPos.y - hitRealpos.y; } }
/// <summary> /// 判断某个位置是否可以下车 /// </summary> /// <returns></returns> public bool CanGetDown(Vector3 pos) { Vector3 origin = transform.position; origin.y += 2.5f; pos = StreamerManager.GetTilePosition(pos.x, pos.y, pos.z); Vector3 drection = pos - origin; RaycastHit hit; if (Physics.Raycast(origin, drection.normalized, out hit, 20.0f, LayerConfig.WalkMask)) { if (hit.distance - drection.magnitude > 0.3f) { return(true); } return(false); } return(false); }
public static Vector3 GetTilePosition(float x, float y, float z) { return(StreamerManager.GetTilePosition(x, y, z)); }