void Update() { Vector2 theMousePosition = XUtils.getMouseWorldPosition(); gameObject.transform.position = new Vector3( theMousePosition.x, theMousePosition.y, gameObject.transform.position.z ); onMouseMove?.Invoke(theMousePosition); }
//-Car control private void Update_CarControl() { //Car movement update if (_isGasIsPressed) { _carPhysics.applyGas(); } if (_isReversIsPressed) { _carPhysics.applyRevers(); } if (_isClockwiseRotatePressed) { _carPhysics.rotateSteeringWheelClockwise(); } if (_isCounterClockwiseRotatePressed) { _carPhysics.rotateSteeringWheelCounterClockwise(); } //Car shooting update if (_isMouseButtonPressed) { foreach (WeaponLogic theGunLogic in _weaponsLogic) { theGunLogic.doShoot(); } } foreach (WeaponLogic theGunLogic in _weaponsLogic) { var theTargetComponent = XUtils.getComponent <RotateToTargetAngleLogic>(theGunLogic); if (!theTargetComponent) { continue; } Vector2 theTurretPosition = theGunLogic.transform.position; Vector2 theDelta = XUtils.getMouseWorldPosition() - theTurretPosition; theTargetComponent.setTargetAngle( Mathf.Atan2(theDelta.y, theDelta.x) * Mathf.Rad2Deg ); } }
private void Update_Input_Mouse() { _isMouseButtonPressed = Input.GetMouseButton(0); _carRelatedMousePosition = XUtils.getMouseWorldPosition() - (Vector2)transform.position; }