Hot answers tagged

10

The edit is reassuring. :) Okay, here's a straightforward update loop... Assuming when we fire the missile we initialize remainingFlightTime = 5f then... void UpdateMissile(float deltaTime) { remainingFlightTime -= deltaTime; // At the end of the trajectory, snap to target & explode. // The math will put us there anyway, but this saves // ...


2

This is a strange behaviour in Unity's scale inheritance system. If the parent has a non-uniform scale, when you rotate the child, they deform/stretch like a rubber band. Try adding an empty child GameObject to Player GameObject and parent the Camera GameObject to empty one, and put the rotation script on Camera. This makes parent of the Camera a ...


1

You can accomplish this by using linear interpolation. https://msdn.microsoft.com/en-us/library/bb197807.aspx float speed = 0.1f; //value between 0 - 1 Position = Vector2.Lerp(Position, DesiredPosition, speed); Another way to do it is to incorporate a time value, while keeping track of the start and end positions. This ensures the movement will be the ...


1

This is the while loop above redone. Kind of ugly and repetitive but it works. I had to use Math.floor and Math.ceil to solve the collision issues which is due to precision I guess. Any spare dt left over if the action sequence is finished is discarded so that might be something to save for accuracy but the timesteps are really small so it may not be ...


1

Math.cos uses radians, not degrees. You want to go from 0 to 2* Math.PI You could do that like this: if (Keyboard.isKeyDown(Keyboard.KEY_D)) { if (i < 360) { //Convert to radians by multiplying by Math.PI*2f/360f float theta = Math.PI * 2f * (float) i / 360f; setX((float) (groundState.getX() + groundState.getRadius() * ...



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