开发者

Game Dev: When will a user expect a collision?

开发者 https://www.devze.com 2023-02-14 22:07 出处:网络
I am writing a basic game and I have what I believe to be a common scenario. I am drawing two lines on the screen and I have done some basic mathematics to conclude that a point on the screen is not o

I am writing a basic game and I have what I believe to be a common scenario. I am drawing two lines on the screen and I have done some basic mathematics to conclude that a point on the screen is not on a line that is being drawn on the screen, however the point and the line are really, really close together. So close that to me it appears as though a collision is actually occurring. Therefore I want to treat everything that looks like a collision (even if it is not a 'true' collision) as one anyway.

Is there any standard precision that people use to make this happen, or some precision ration per screen resolution or something similar? If you could point me in the direction of anything standard that would really help too.

Also, there is the fact that I am using floating point values and that they will loose precision over multiple calculations anyway so knowing what level of prec开发者_如何转开发ision I can get away with is pretty important.

Edit:

Here are some links on precision in games that I have found:

  • A Matter of Precision


Of course you can always treat the point as a tiny circle with a radius slightly larger than its pixel size for collision-detection purpose. You might also consider "stroking" the line and/or the point with a brush size larger than 1 pixel to get a display resolution independent look. Collision detection still reduces to line vs. circle checks because you can add the brush radii.

Regarding the users expectation: I found it quite annoying to be treated as collided even though there was a minor gap between my game object and the obstacle. It occurs in many racing games and it's really all about driving close to the limit there. Thus "eager" collision detection for player objects is a bad thing. Nobody will complain if luckily being treated as not-collided even if it looked a bit like that.

On the other hand for non-player objects I would consider it a good idea to eagerly check collisions. The rationale is the same: Nobody will complain if the enemies are treated less favorable.

0

精彩评论

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

关注公众号