Box2d 布娃娃自定义动画
我有一个布娃娃,完全由物理控制,但我想自己控制它,添加动画,当我点击身体的每个部分时,它的行为完全是物理的
我所做的是
- 完全用物理和关节创建布娃娃
- 能够拖动它的任何部分
- 将状态设置为动画,并将每个人的状态更改为运动学
我现在想做的是独立地对每个部分执行我的动画,我的意思是,改变它的位置和角度,问题:
- 当我转动手臂和腿,从中心旋转,我希望它从“关节点”旋转,这样我就可以通过简单的 setTransform(pos, angle) 控制手臂角度,
我怎样才能实现这一点?
I have a ragdoll, completely controlled by physics, but I want to controll it by myself, adding an animation, and when I click on each part of the body, it acts completely physical
What I did was
- Create the ragdoll completely with physics and joints
- Be able to drag any part of it
- Set state as animation and it changes the state of everybody to kinematic
What I want to do now is perform my animation to each part independently, I mean, change its position and its angle, problems:
- When I rotate the arm and the legs, it rotates from the center, and I want it to rotate from the "joint point", so I can controll the arm angle with a simple setTransform(pos, angle)
How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,当你的角色被杀死时,会使用布娃娃来模拟它的真实坠落。所以我认为你并不真的需要一直对你的角色进行物理模拟。更重要的是,如果您只是设置它的位置,无论如何您都会得到非物理行为(您的角色的每个部分至少应该有正确的速度,否则由于碰撞处理不正确,模拟将不现实)。因此,通常只需制作一个 AABB 或绑定球体来控制角色移动时的碰撞就足够了。当角色死亡时 - 制作一个布娃娃来模拟死亡。所以我建议你将角色的图形和物理表示分开,死亡除外
Usually ragdolls are used when your character is killed to simulate it fall realistic. So i don't think you really need your character to be physical simulated all the time. More of this, if you will just set it's position you will get non-physical behavior anyway (you should at least have correct velocities for every part of your character, otherwise the simulation will not be realistic because of incorrect collision processing). So usually it's enough just to make an AABB or a bound sphere for controlling collisions with you character while moving. When the character dies - make a ragdoll to simulate the death. So i suggest you to separate graphical and physical representation of your character except death