Tag Info

New answers tagged

1

First use Zehelvion answer to make the car turn correctly, then: Use the timestamp, you measure how much time it took for your last iteration and use that to modulate the speed at which you are changing things. void RunGame(float deltatime) { if (key.KeyCode == Keys.Up) { Player1.speed += accelaration * deltatime Player1.speed = ...


5

Start by adding a variable for the angle that the car is moving at. float angle = Math.Pi / 2; Then add a variable for the current speed. float speed = 0.0; Now create three constants: public static final float acceleration = 0.1; public static final float maxSpeed = 5.0; public static final float rotationRate = Math.Pi / 50; For starters, get your ...


0

In neutral position you have defined forward to be the positive Z vector (0, 0, 1). There are two vectors perpendicular to that vector (if we ignore sign), up (0, 1, 0) and left (1, 0, 0). The easiest thing would be to create all three vectors and to apply a matrix transformation to find the left, up, and forward vector in 'camera space'. Matrix transform ...


5

You're on the right track. I would start by determining the player's direction based on the keyboard state: direction = Vector(0, 0) if up pressed: direction = direction + Vector(0, -1) if down pressed: direction = direction + Vector(0, 1) if left pressed: direction = direction + Vector(-1, 0) if right pressed: direction = direction + ...


2

If I understand your problem correctly, you wish to determine, for a given initial location, initial velocity, desired target, and constant magnitude acceleration, what constant point the acceleration must be aimed at in order to pass through the desired target point at some future time. This is the definition of circular motion around the aiming point, ...


1

The distance moved does not take the delta time into account, so if you get updates coming at an irregular interval you'll get jerky motion. Scale your speed by the elapsed time, dt; public void update(float dt){ if(cont == true){ vec = makeVec(); x += vec.x * speed * dt; y += vec.y * speed * dt; } } This might mean you'll ...


2

When facing this problem I found that I wanted the character to move forward at a velocity roughly proportional to how close they are to facing the target. When facing away from our target we "turn on the spot" (Red), when facing directly towards it we walk straight towards it (Green), when somewhere in between we will may walk slowly while turning (Blue ...


1

In a first person camera, you can move the camera forward by adding the camera.direction values, scaled by speed * delta values, to the camera position. This moves the camera forward in the direction that the camera is facing. To move the camera forward on just the X and Z planes, you add camera.direction.x and camera.direction.z to the position. Create a ...


2

You've discovered the equation for constant linear acceleration. This equation is used in situations of uniform acceleration to determine final position and velocity. Essentially you start with your acceleration and integrate with respect to time to get the equation for velocity and integrate that for the equation for position. a = a //Acceleration v = ...


0

Some games define rectangular area of the screen that the player can move about in without causing camera movement. Any movement outside of this area will cause the camera to move to compensate. This allows the player to make small movements (e.g. adjusting position on a block or jumping on an enemy) without shifting the camera. Shaun Inman has posted a ...


0

I call the way I do it the rule of the two thirds. Basically the screen height is split in three, and level design is done accordingly to these part sizes. Player avatar is always in the middle part. When she jumps to a higher platform contained in the top third of the screen, the camera moves to center the player. When player reaches the lowest part the ...


0

There is no reason for the Map and Player objects to communicate at all that I can see. So far as what you've told us we can assume that Player object only holds data about their position, but then what does the map hold? (rhetorical Q). It sounds like the objects are doing the same job. I.e. the map already knows the Player object's position. If your map ...


0

I think some trigonometry classes would help you. Meaning of variables position.x is the x coordinate, and position.z is the y (if 2D game) or z (3D game) coordinate. Yaw is the rotation (in radians I think). So when user presses A do yaw--; and when user presses S do yaw++;. Distance is how far to move (sort of like speed). NOTE: This is written in Java. ...


2

Your question is a bit wider than you exposed I think. Player and Map are two objects and should be thought as it. They are not different, from an engine point of view, of a ping-pong table or a flying toaster. That said the question is : how to make NORMAL objects findable and communicate? For a map / player relation I usually put responsability... on a ...


3

One way to do it is to keep track of the Front and Up normalized vectors and transform the front vector whenever your character turns, and calculate the Right vector using cross product ( I am assuming Up vector won't rotate). Or you can keep track of the three vectors and rotate them. Once you rotate them you update the position by adding the offset in the ...



Top 50 recent answers are included