在头顶赛车游戏中汽车/车辆在拐角处漂移
我已经实现了一个非常基本的汽车运动系统:
_velocity.x = Math.cos(angleAsRadians) * _speed;
_velocity.y = Math.sin(angleAsRadians) * _speed;
_position.x += _velocity.x;
_position.y += _velocity.y;
您通过增加/减少速度来移动,并通过增加/减少角度来转弯。
如何添加漂移,以便转弯时速度越快,漂移就越多?我无法弄清楚,而且几乎没有其他可通过谷歌搜索的来源。
有想法吗?
I've implemented a pretty basic car movement system:
_velocity.x = Math.cos(angleAsRadians) * _speed;
_velocity.y = Math.sin(angleAsRadians) * _speed;
_position.x += _velocity.x;
_position.y += _velocity.y;
You move by increasing / decreasing speed and turn by increasing / decreasing the angle.
How can I add drifting so that the faster I'm going, as I turn, the more I drift? I can't figure it out and there's next to no other google-able sources.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
汽车物理学有点棘手。您需要的是实现一个基于滑动的物理引擎。
本文解释了该过程相当好。为了使其正常工作,需要考虑车轮的旋转以及轮胎向一个方向行驶而地面向另一个方向行驶时的力差。事实证明,这是两种力,一种垂直于车轮的轴线,另一种相对于汽车横向。
当然,这是大量的工作,在做任何与游戏相关的事情时,一般规则是如果看起来不错就是好的。因此,人们可以从实际物理的实现方式中获得一些经验和想法,并采取一些适当的解决方案,以创建真实交易的可信复制品。
Car physics are a bit tricky. What you need is to implement a slip based physics engine.
This article explains the process fairly well. In order to make it work properly one needs to take into account the rotation of the wheels and the difference of forces when the tyre is going one way and the ground goes another direction. This turns out to be two forces, one perpendicular to the axis of the wheel and one going sideways in regards to the car.
Of course, this is a lot of work, and when doing anything games-related the general rule is if it looks good it is good. So, one can get some mileage and ideas from how the actual physics is done and take some bits and pieces of the proper solution in order to create a believable facsimile of the real deal.
确定“漂移系数”,例如速度乘以时间的 0.5% 的距离。
所以在这种情况下它是可加的,并且基于速度。
该系数还可以根据赛道半径、任何比赛条件(打滑等)等因素而变化,x 轴和 y 轴之间存在差异,并随机为正或负。
Decide upon a "coefficient of drift", like a distance that's 0.5% of the velocity times time.
So in this case it's additive, and is based on the velocity.
This coefficient could also be variable based on something like the track radius, any racetime conditions (slippery, etc), differs between x and y axis, and randomized to be plus or minus.