void Update_EntityVelocity() { Vector3 acceleration = Vector3.zero; //TODO: Consider whether it's best to store a pointer to the respective SettingsInput class or to just have direct pointers for each controller class.. int i = 0; foreach (Direction dir in InputBindings.dirBindings.Keys) { float dirInput = InputBindings.dirBindings[dir].Magnitude; //Did we receive an input from this axis this frame? if (dirInput == 0) { //TODO: Getting this to work is an urgent priority! //If not, then factor in any deceleration we need to apply. //What is the Velocity of this Entity in this direction? //Take the magnitude of this Velocity and clamp it between a range of 0 and 1. } acceleration += BaseDirections.VectorInDirection(transform.rotation, dir) * dirInput; i++; } velocity += acceleration * 15F * Time.deltaTime; //TODO: For debugging purposes only. Remove this ASAP. if (Input.GetKeyDown(KeyCode.Escape)) { velocity = Vector3.zero; } transform.position += velocity * Time.deltaTime; Character.Transform.Position += velocity * Time.deltaTime; }
void Update_BuildingPreview() { if (IsBuilding) { m_previewDistance += Input.GetAxis("Mouse ScrollWheel") * 5F; m_previewDistance = Mathf.Clamp(m_previewDistance, 2F, 8F); if (Input.GetKeyDown(InputBindings.nextOrientation)) { m_previewOrientation = BaseDirections.GetNextDirection(m_previewOrientation); m_previewRotation = BaseDirections.GetRotation(m_previewOrientation); } if (Input.GetKeyDown(InputBindings.prevOrientation)) { m_previewOrientation = BaseDirections.GetPrevDirection(m_previewOrientation); m_previewRotation = BaseDirections.GetRotation(m_previewOrientation); } Ray fromCamera = new Ray(transform.position, transform.forward); ShowPreviewAt(fromCamera.GetPoint(m_previewDistance), m_previewRotation); } else { Destroy(m_preview); m_previewDistance = 3F; } }