Tag Info

Hot answers tagged


Use Transform.TransformDirection() method where Transform is your player transform. // Calculate the x-axis relative to the camera camera = Camera.main.transform; cameraRelativeRight = camera.TransformDirection (Vector3.right); // Apply a force relative to the camera's x-axis rigidbody.AddForce (cameraRelativeRight * 10);


You can use Quaternions instead of Euler Angles to solve this. transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(rotationDestination), Time.deltaTime * rotationSpeed); If you want to test distance still, you can use... if(Quaternion.Angle(transform.rotation, Quaternion.Euler(rotationDestination)) > 0.2f) I'd suggest you ...


There is (IMO) nothing wrong with your general approach. The function is nonlinear, so there's going to be some involvement of {if ?: abs sgn floor ceil} or the like somewhere. Your code won't work quite right though. Won't (0.707, 0, 0.707) snap to (1,0,1)? Similarly, (0.44, 0.9, 0.0) would snap to (0,0,0). There's four possible results, which can checked ...


According to the docs for DrawTextA, "the return value is the height of the text in logical units". So you should modify your DrawString function to return this value (plus one, since you draw the shadow one pixel lower). You'd then offset the calling function's y-coordinate by the returned value, plus whatever padding you want. So something like this: ...

Only top voted, non community-wiki answers of a minimum length are eligible