So I have been using Farseer for a platformer with physics, and I started running into some concerns as shown below:
When I want my character to jump, I don't only want to apply an impulse to the character body, but more realistically, the character body should be pushing down on objects below it (1) thus propelling itself upwards (2).
The same applies when I want my character to move. When the character moves, it should apply force and push off the objects below it (1), not carry the object with it and thus moving in the opposite direction (2).
Although I will be using skeletal animations for this game, I would like to keep it to be a bounding-box shape. This will be a networked game, and the physics will be handled via the server. I prefer to avoid server stress, so I will keep characters to a bounding box and keep all skeletal animations to the client side.
So here are my questions:
Am I forced to "fake" these forces?
Is it reasonable to duplicate skeletal animations on the server side,
and just use capsule bodies for the different bones of each character?
Will this be too intense?
The game should be able to support 20-30 people per room over multiple rooms. If it comes to it, I would like to avoid very heavy server stress.
I tried to post this to GameDev, but I don't have the reputation to post images there yet, so I will try to find an answer here first.
Instead of applying a force in the direction you want your player to move, apply it in the opposite direction. This will essentially create a collision, and the box will push your character up. If you play around with the body restitution property, you might be able to reach an acceptable "bounciness" that could work for you.
You would need to check if your player is resting on top of a box first, or else your player will just fly downwards.
Farseer bodies should keep track of any current collisions, this is how the character knows it is supported by something underneath. I would recommend applying a force to whatever the character is supported by, and if you are going for realism, take into account the mass of both the character and the supported object, and how high the jump is going to be. Whatever is calculated as downward force to be applied to the supporting body should be reversed and also applied to the character.
If you want to try and use Farseer to make this happen, rather than calculate it yourself, you might be able to do this using springs, but otherwise pushing down on the supporting object isn't going to get the player to push upward.
Related
I'm just wondering how to make shots in my game more realistic. I mean there are two main ways in implementing shots. First: throw a small projectile and let it detect collisions. Second: use raycast. But in real world (and apparently I noticed this in PUBG) bullets fly really quick but not immediately. Here is why you should aim near your target if it's far away from you to hit it. Because if you aim right where it is it will move and your bullet will miss the target.
I'm just curious if any of you, guys have a nice solution to this problem. Also I wish to find a way to use raycast not every frame. In such things like detecting if you will actually hit the wall when shooting. If you have any good ideas how to implement spread and recoil for different types of weapons I will be happy to read them.
Blue point is bullet point of frame. and in very frame send a new raycast to check cross any human. like red line in this picture.
and bullet path use unity built-in Physics system to do it.
NavMeshSurface.BuildNavMesh();
I want to do "Bake" of NavMesh dynamically. My game is like Minecraft.
I move the MOB around the world. Player can place blocks. So, if I do BuildNavMesh() I will be able to "Bake" NavMesh with new blocks.
Blocks is placed by the player. And every time player puts a block, I do BuildNavMesh(). Players can jump on them. Player can also destroy those blocks.
As I mentioned earlier, I do not know what to do other than that.
I can only write the above code.
NavMeshSurface.BuildNavMesh();
The best result I want is to use NavMesh to dynamically change the MOB's range of motion.
My navmesh was also building extremely slow. 2 things that really helped were:
play around with the tile size on the NavMeshSurface component, the smaller the faster it will build but it has some tradeoffs.
remove unnecessary layers from you NavMeshSurface component. And this was really the biggest issue. I had the default layer and ui layers in there which caused a big lag, removing them almost instantly rebuilds the navmesh in runtime!
I'm new to Unity and I'm making a car racing Game. Now, I'm stuck at some point. I was looking for some solution of my problem, but couldn't succeed.
My problem is:
When I run my game on my phone, it sticks badly because whenever there are several buildings in front of the car camera, like one building behind another building, it lags. Reason for this is there are so many vertices and edges at that time, So the Car Camera is unable to capture all that stuff at same time.
How do I preload the 2nd Scene while loading 1st Scene?
I am using Unity free version.
In graphics programming, there is a common routine to simply don't draw objects that aren't in the field of view. I'm sure Unity can handle this. Check link: Unity description on this topic
I'm not hugely knowledgeable about Unity, but as a 3D modeller there's a bunch of things you can do to improve performance:
Create a simplified version of your buildings with fewer polygons for use when buildings are a long way away. A skyscraper, for example, can be as simple as a textured box.
If you've done that already, reduce the distance at which the simpler imposters are substituted for the complex versions.
Reduce the number of polygons by other means. A good example is if you've got a window ledge sticking out of the side of a building, don't try and make it an extension of the body. Instead, make it a separate box, delete the facet that won't be seen, and move it to intersect with the rest of the building.
Another good trick is to use bump maps or normal maps to approximate smaller features, rather than trying to model everything.
Opaqueness. Try not to have transparent windows in your buildings. It's computationally cheaper to make them just reflect the skybox or a suitably blurred reflection imposter. Also make sure that the material's shader is in Opaque mode, if it supports this.
You might also benefit a little from checking the 'Static' box on the game object, assuming that buildings aren't able to be moved (i.e. by smashing through them in a bulldozer).
Collision detection can also be a big drain. Be sure to use the simplest possible detection mesh you can - either a box, cylinder, sphere or a combination.
I am building a game in XNA 4.0, where a player moves about a 2 dimensional (vertical perspective) map consisting of blocks. My issue is creating proper collision between the payer and the blocks (basic game physics.) The player moves more than 1px per frame, so .Intersects() just isn't enough, I need physical contact collision that can function in a gravity environment. The current version I currently have is a piece of garbage and only works occasionally.
Basically, all that the collision system needs to do is stop gravity when the player lands on a block, and provide some decent physics when the player hits blocks (movement in that direction ceases). The idea behind my current solution is to move the next Position around until it finds a clear spot, but it doesn't work well. I have an idea why, just have no idea how to do it properly.
I know there must be a better way to do this. What would be the best method of making this kind of collision work properly?
Thanks
This does the job perfectly, you just need to sort through a few syntax errors. http://go.colorize.net/xna/2d_collision_response_xna/
I have been coding for some years in C# and have now decided to try out the XNA framework to make games.
It went great until I started to implement collision handling in my very simple game.
I can understand how to do collision detection using BoundingBoxes and BoundingSpheres, but after looking at the refresh rate in my game, it quickly became a concern of mine if the two colliding objects were never detected as colliding.
Let me try to explain with an example:
- If a character is shooting with a gun at another character.
- The bullet is heading straight for the other character.
- The bullet gets rendered just before the character.
- Because of the bullets high velocity it now gets rendered on the other side of the character.
In this scenario the bullet and the character never collides, because they are never rendered in their colliding state.
So how do you make sure to detect a collision in this scenario?
For very fast-moving objects, the regular approach fails in the scenario you described. What you need to check for is whether the bullet has collided with any item in the interval between the two consecutive game ticks. This is called continuous collision detection (this is a rather related SO post).
You can do this by basically casting a ray between the middle of the bullet's binding box in the current position and the middle of the box from the old position, and checking if that collides with any other blocks/spheres. This is a rather fast solution and if your bullets are small enough, it should work fine.
For more precision, you can cast four different so-called collision rays from each corner of the current bullet box, to their corresponding positions from the previous game tick. Note that in the rare event of high-speed items smaller than bullets, this might also fail. In this case you would need a more advanced collision detection system. But this would just be a corner case.
If that extra precision is a must, a free 3D physics library, such as Bullet could represent a solution. It even has bindings for XNA!
I think your problem is in tunneling that matches your description.
I recommend you to use Box2D physics engine for XNA. It's fast, simple and will avoid your any problems with collisions in your game.
Check in this manual on 4th page continuous collision and check how Box2D deal with tunneling effect.