开发者

Vectors and physics in games

开发者 https://www.devze.com 2023-02-05 18:59 出处:网络
Can forces be stored as dot products? such as the gravity on a planet. And for a game, for example a 2d spaceship game. would one add a right thrust vector and a left vector to power the ship and mov

Can forces be stored as dot products? such as the gravity on a planet.

And for a game, for example a 2d spaceship game. would one add a right thrust vector and a left vector to power the ship and move it around. then 开发者_运维问答this would mean the angle of the ship shown on screen is computed from those vectors and the player would have no control over the actual angle of the ship.

Is this correct?


Can forces be stored as dot products? such as the gravity on a planet.

This makes no sense whatsoever. A force is a vector; dot product is the scalar product of two vectors.

And for a game, for example a 2d spaceship game. would one add a right thrust vector and a left vector to power the ship and move it around. then this would mean the angle of the ship shown on screen is computed from those vectors and

the player would have no control over the actual angle of the ship.

Huh?

Would you allow the player to vary the magnitudes of either vector? If yes, then they have some control.

What does "left" and "right" vector mean to you? What do they mean if the ship rotates 90 degrees? Do they become "up" and "down"? How does that change things?

Would you agree that if you have "left" and "right" vectors of equal magnitude that sum of forces in the x-direction is zero and the ship will not accelerate at all? (You make no mention of vectors in the y-direction, so I'll assume that the sum of forces in the y-direction is zero, too.)

Is this correct?

No.

Your understanding of Newtonian mechanics is equal to your current acceptance rate.


As for your first question, yes. Why wouldn't you be able to? Though I would store gravity as just a value, and then calculate the weight of the object.

If I understand you, you are asking whether you should have the right key of a spaceship as a vector force to move left or to have the right key rotate the ship? The first idea seems more logical; if your spaceship is stuck in a place such as this:

  _
 |*|
 | |
_| |___
|_______

(Excuse my poor ASCII; it's meant to be a ship stuck in a vertical dead end) your first solution would cause the ship to ricochet in the tunnel. Your second solution (applying a rotation directly) would simply have a ship rotating. Which would seem very unnatural if the tunnel was narrow.

Look up rotation matrices.

0

精彩评论

暂无评论...
验证码 换一张
取 消