开发者

XNA Farseer - How to actually make it work?

开发者 https://www.devze.com 2023-02-18 07:34 出处:网络
I have im开发者_如何学运维plemented the Farseer engine into my 2D XNA platformer project. I created a Body using an image of piece of terrain which loads and draws nicely, I created a second body whi

I have im开发者_如何学运维plemented the Farseer engine into my 2D XNA platformer project.

I created a Body using an image of piece of terrain which loads and draws nicely, I created a second body which is the player and it draws but doesn't do anything.

How do I make the Player body object actually work and apply gravity and collide with the terrain object?

I have searched high and low and can't seem to find many tutorials/guides on how to do the basic stuff with farseer.


I believe there is a property called BodyType or something similar that you need to change for anything to actually happen to the body. The default is for the body to not take part in physics simulations, so you need to change it in order for things like gravity to work.

Another thing worth noting is that bodies will automatically go to sleep when the engine doesn't think anything is going to happen to them, so if something isn't behaving the way you would expect try changing the value.

I would recommend looking through the Box2D Manual because for the most part Farseer replicates the original Box2D API. Things like memory management, obviously, are different because of the way the .Net framework works. Some experimentation may be necessary.

0

精彩评论

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