Planetary Quadtree Terrain for RTS (Mesh Collider / Pathfinding Issue) - c#

I've been plucking away at a capital ship real-time strategy game, and I'm getting ready to start implementing a ground to space invasion system -- but I can't seem to wrap my head around how ground unit pathfinding would work if a Quadtree LOD system is being used.
Most ground-to-space games I've played seem to generate mesh colliders on the fly as you get closer to the ground, and the quadtree subdivides; with that comes all the NPCs that pop into existence for the first time and use said colliders, but I'd like my units to have a persistent presence as the player zooms in and out from the planet -- but I feel that having dynamic terrain and mesh colliders would mess up unit pathfinding, or they may glitch in and out of the terrain for example.
Does anyone know if this issue has been tackled in a game before? My gut tells me that you'd need a persistent mesh collider, which would mean the planet couldn't have much variation (to keep the collider poly count down).
Thanks for your time!

Related

How do I stop jittery movement in Unity game?

My 2D game is not lagging, but for some reason the entire game world (except the player) is jittering when the player/camera moves. I tried parenting the camera to the Player and I tried using a script to make the camera move to the player, but it didn't help. It is worse if the framerate is lower, or if there are little frame drops. I use velocity to move the player. Using FixedUpdate (for the player and the camera) didn't help either, it just makes my player not jump every time I press the jump button. I tried searching but I didn't find a solution.
Honestly this is a really difficult and tedious problem to troubleshoot.
I've had issues previously with moving a game object by transform that had a rigidbody.
I've had issues where a rigidbody parent had a child with a rigidbody - also never do this, each hierarchy should have one and only one rigidbody, and that should be at the root level. A rigidbody will "inherit" or consider colliders at all levels at or below the rigidbody in the hierarchy.
I've had issues with a rigidbody that didn't have a collider.
I've had issues where the camera was attached to the rigidbody.
I've had issues where the interpolation settings were not set.
I'd really need to browse through the project and look at the setup to give any kind of specific feedback. Otherwise I'll say that rigidbodies and rigidbody motion is such a pain in the ass that I would recommend NOT using them unless you absolutely have to.
You can do collision checks as triggers without rigidbodies. You can code your own movement and gravity system pretty easily for 2D. The only thing you really need physics for is if you want to solve physics-based collisions, and there I would again say don't use it if you can help it. You can also programmatically add a rigidbody, like for a combat knockout, and add the knockout force and direction, but all the rest of the combat is using scripted motions.

Effective way to make NavMeshAgents jump/climb obstacles in Unity?

So I'm working on a zombie game and I want my zombies to be able to climb/jump over certain obstacles around the map. I know that I can create nav mesh links to achieve this but when doing it it feels forced as the zombies will go to the link to connect the climb/jump instead of just going over the obstacle. I am having trouble in my research finding an effective way to do this.
Basically here is what I want to achieve:
1.) When a zombie reaches a certain obstacle (fence, car, crate, etc.) that is climbable, instead of running around the obstacle to get to the player I want the zombie to climb or jump over the obstacle.
2.) When the player climbs on top of an obstacle I want the zombies to also be able to climb on the obstacle to be able to attack the player.
Does anyone have suggestions on effective ways to go about this or possible methods I could further research? From the hours I've spent researching this I'm not having any luck finding something that goes with what I want to achieve.

Unity3d - Evaluate enclosed rooms by walls components

I am working on Sims-like building system.
I am at the point where I can create walls at runtime, but my problem is that I need to know when a list of adjacent walls create a well-enclosed room.
My code so far is pretty messy, so apologies if I don't provide any.
The setup is pretty simple, it is 3D environment where each wall is just a cube (see image below).
The game should allow players to build their own rooms made by walls prefabs (again, they are just cubes stiled as walls).
Any idea how to achieve this?

Controlling Player Movement After Per Pixel Collision

I have implemented a full per pixel collision system that accounts for rotation, and its very accurate. It returns a simple bool on collision.
However I am not sure how to handle the collision from the player movement point of view.
E.g. In the picture above, if the player is holding up on the left stick, he should be stopped, but if he is holding up + right diagonal on the left stick, he should slide northeast alongside the side of the red square almost naturally.
How do I go about this, to make the player’s momentum stop, but still give control for the player to move in direction not blocked by a collision.
I could do this kind of thing with simple untransformed rectangles, but going into per-pixel texture collision has made my brain explode today so I’m hoping you guys can help. Any advice would be massively appreciated.
It is possible. For that you need to implement physics engine with your pixel based collision if you are willing to give natural effect in your game.
For that either you write your own game engine or use engine that is already there. For 2D game I highly recommended Farseer Physics Engine. It is out there for a long time. Now in stable condition and it surely wonderful.
It is developed using XNA only from scratch, and also performance wise it is far good.
Have a look at this. I hope I was able to give you answer. Please let me know if more details needed.

XNA collission detection vs. game speed

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.

Categories

Resources