So I want to have air time in my game, but I can't figure out how to check the collisions of all my wheels. I can only check whether a single wheel is colliding with the floor, not if all of my wheels are colliding with the floor.
Sorry for the poor wording, but the goal is to check to see if any of the four wheels are touching the floor.
There are several ways to achieve this, but one would be to create multiple Colliders for each wheel. Then you check whether each of these wheels is currently touching the ground. So you would have an extra Collider Object per wheel to check this.
Another way would be that if you have like one Object as car you could check the positions your object is having collisions with and calculate them but that would be way to complicated because I dont think performance will be that important for you.
Related
I am trying to get a player pull and push objects in my 3D game. I am mainly focusing on pulling and pushing a box. Now when a player collides with a box and the E key is pressed the isKinematic of the box becomes false, and the player is able to move the box with its own mass.
I am trying to implement a basic pull and push interaction of the object. I have been thinking moving the box along with the movement of the player based on the WASD input but it doesn't sound stable, which road should I take here? Should I use a Fixed Joint connect them? I tried putting the fixed joint the box and making the connected body the player, but now the player is not able to move like there is a collision around it.
What is the best way to implement this? Should I use Fixed Joint or take a different way? Thanks.
if you really want to work with physics, i would say use a rigidbody. Use the rigidbody.AddForce or rigidbody.velocity to move your player. or use the transform by lerping to the position, but this is a bit messy and could not register all of the collisions if you are working on a fast object.
I am kind of new to unity,to any kind of engine,actually.
I am trying to find a way to have a controllable mass of fluid,i mean to be able to go forward,back and so on using the arrow keys.
At first i thought about having some kind of mesh filled with simulated liquid but it doesn't really fit for my project....
Long story short, i need to be able to move a droplet of water.
I think you should start with instantiating just a lot of balls (2d or 3d) - as a representation for droplets. You can give them all physics colliders and rigidbody mass and you will be able to control them all, by proximity or individually.
In the future you can replace spheres with some kind of surface-generating algorithm like metaballs or raymarching
i am developing a racing game. But it's not your usual racing game, the bike is supposted to always have the Y coordinate of the same value as the closest point on the map mesh, in other words it is ALWAYS touching it.
What i do not want is the Y coordinate to be dependent upon the X and Y position, as there will be 2 (or maybe more floors).
I have absolutely no idea how to implement this. Completly zero. I am rather new to scripting, and this i way out of my league, i don't even know how to start... The map is not a simple plane, so simple maths won't help.
I'll apreaciate any help at all, not necessarily a solution.
Thanks in advance
This idea is an adapted version of #LeoBartkus's
I suggest using 2 raycasts from the bottom of the bike's wheels and using the 2 hits to position and rotate the bike. This allows for an accurate positioning of the bike for all kinds of terrain, except for spikes narrow and tall enough to appear to pierce the bike. Using a single raycast from the bike's center might cause problems if the ground is uneven, like a crater for example
I have my players on a screen and the enemies spawn fine and go toward whatever player is closest. If I add a wall however and the wall is in between the player and enemy, the enemy will stay at the wall, trying to go through it. How could I go about this to make the enemy maneuver around the wall before it gets to the wall?
There are a multitude of different algorithms that can be used for making this kind of path-finding. Have a look at this nice example for an A* algorithm in C#.
You'll need some AI algorithms to help your enemies maneuver, which I will not talk about in detail here but I shall tell you where to look further. Assuming your players can only to certain locations on the map (like cells on a chessboard), the problem can be easily solved by treating the map as a graph with node and edges then trying to find a path between 2 points.
If you're lazy to read the algorithms and implement them, a very easy approach is just let the enemy "find" its path randomly: if it hits a wall, the enemy will randomly pick another direction to continue. It's sort of like a robot which turns 90 degree every time it hits a wall; it's not efficient but you'll get there.
If the players can move anywhere in the map (in other words their locations are not confined to cells), you'll need some algorithm that takes the geometry of the walls into account (sort of like a convex polygon) and find the shortest path around each object.
I'm designing a 3D game with a camera not entirely unlike that in The Sims and I want to prevent the player character from being hidden behind objects, including walls, pillars and other objects.
One easy way to handle the walls case is to have them face inwards and not have an other side, but that won't cover the other cases at all.
What I had planned is to somehow check for objects that are "in front" of the player, relative to the camera, and hide them - be it by alpha blending or not rendering at all.
One probably not so good idea I had in mind is to scan from the camera to the player in a straight line and see if you hit a non-hidden object, continuing until you reach the player. Unfortunately, I am an almost complete newbie on 3D programming.
Demonstration SVG illustration < that wall panel obscures the player, so it must be hidden. Another unrelated and pretty much already solved problem is removing all three wall panels on that side, which is irrelevant to this question and only caused by the mapping system I came up with.
What I had planned is to somehow check for objects that are "in front" of the player, relative to the camera, and hide them - be it by alpha blending or not rendering at all.
This is a good plan. You'll want to incorporate some kind of bounding volume onto the player, so the entire player (plus a little extra) is visible at all times. Then, simply run the intersection algorithm for each corner of the bounding volume.
Finding which object is at a given point on screen is called picking. Here's an XNA link for you which should direct you to an example. The idea is that you retrieve the 3D point in the game from the 2D point, and then can use standard collision detection methods to work out which object is occupying that space. Then you can elect to render that object differently.
One hack which might suffice if you have trouble with the picking approach is to render the character once as part of the scene, and then render it again at the end at half-alpha on top of everything. That way you can see the whole character and the wall, though you won't see through the wall as such.
One easy way, at least for prototyping, would be to always draw the player after you draw the rest of the scene. This would ensure that the player is rendered on top of anything else in the scene. Crude but effective.
Create a bounding volume from the camera to the extents of the player, determine what objects intersect that volume, and then render them in whatever alternate style you want?
There might be some ultra-clever way to do this, but this seems like the pretty straightforward version, and shouldn't be too much of a perf hit (you're probably doing collision every frame anyway....)
The simplest thing I can think of that should work relatively well is to model all obstacles by a plane perpendicular to your ground (assuming you have a ground.) Roughly assuming everything that is an obstacle is a wall with some height.
Model your player as a point somewhere, and model your camera as another point. The line in 3d that connects these two points lies in a plane that is particularly interesting to you, because if this plane intersects an "obstacle plane" below the height of the obstacle, that means that that obstacle is blocking your view of the player point.
I hope thats somewhat clear. To make this into an algorithm you'd have to implement a general method for determining where two planes intersect (to determine if the obstacle is tall enough to block view.)