How to create whirlpool/vortex effect?(如何创建漩涡/漩涡效果?)
问题描述
我试图在作为传感器的圆形体上制作涡流效果.我一直在寻找这个,我寻找的所有示例都是用 C++ 或 Objective C 编写的,我似乎翻译得不好.
Im trying to make a Vortex effect on a Circle Body that is a Sensor. I've been looking for this and all examples i look for are in C++ or Objective C and i dont seem to translate them well.
当我的对象碰撞时,它会调用 beginContact(..) 并设置一个标志,以便我可以调用 bodyToUpdate.applyForce(...);
when my objects collition, it calls beginContact(..) and it sets a flag so that i can call bodyToUpdate.applyForce(...);
如何计算每帧施加的力使其成为漩涡?
how to calculate the amount of force to apply every frame to make it a vortex?
所以我现在让物体直接进入漩涡的中心,但没有旋转"
so i now have the object going straight to the center of the vortex, but no "spin"
推荐答案
你想实现一个切向力,其大小向涡流中心增加.
You want to implement a tangential force with a magnitude that increases towards the center of the vortex.
这是一些伪代码.
这是显示矢量分量的图像:
Here's an image that shows the vector components:
要创建漩涡效果,当物体靠近中心时,应增加径向 (Fr) 和切向 (Ft) 力.
To create a whirlpool effect there should be increasing radial (Fr) and tangential (Ft) forces as the object moves closer to the center.
这篇关于如何创建漩涡/漩涡效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!