How do you stop character in unity from overlapping with Platform? - c#

Hi, as you can see from the above image, my player sinks into my platform. This is because
the platform isn't a flat surface. How do I stop the player from sinking into my platform?
So far I have tried to use layers, but I don't think this works for 3D objects. This is my first time creating a 3D game.
UPDATE: I've added colliders to both objects, but it still sinks.

Probably collider shape/placement. Possible reasons:
one or more colliders are not the shape you think they are. (click edit collider on its component to visualize
one or more colliders is set to isTrigger.
Concave generated mesh colliders can have unexpected results.

Related

How do I make dynamic 2D collisions faster in unity?

Currently I'm working on a 2D game with destructible terrain in unity. It works great! Except for one thing.... collision generation... Since the terrain is destructible, I have to generate collisions on the go. I tried and it's awful performance. From 1000 fps from editing the terrain to 1 fps when I enable collisions generation. This is a huge issue and I know it's possible within unity because this guy :
https://forum.unity.com/threads/wip-nimbatus.221798/
created it with collisions as well. I tried contacting him but no response yet! Any of you guys have any ides on what I can do? Thanks!
I found a rather annoying but working solution to the issue. So basically what was wrong was I was setting points as vertices. The guy I messaged told me that at the time when he made his game, the 2D engine wasn't a thing in unity so he was forced to use regular 3D components. I didn't want to do this because it would possibly limit what I can do with 2D packages since I am not using the 2D engine. But in the end I decided that unless I could find a extremely fast edge finding algorithm that supported concave meshes WITH holes, I would need to just use the regular Unity3D MeshCollider component. I'm not sure why I was having an issue with the Polygon collider as I thought it would work the same as the MeshCollider but in 2D. I think the issue was I was setting the path of the Polygon Collider as each vertice. This is wrong because I think I would need to set the edge vertices only. (My mesh does not share vertices so I'm not sure how to find the edges) Of course I could re write it to share vertices but I think I will be find with the 3D components (For now at least)

How to create multiplayer / shared AR game with Vuforia?

I would like to create a shared AR game on Android phones, where I would like to:
spawn a cube for each player on an ImageTarget
allow them to control the position of their cube
allow them to see the movements of all players' cubes
I'm using Vuforia as my AR library and PUN 2 as my networking library. I have no issue synchronizing the positions and rotations of all cubes. However, the cubes do not stay on the ImageTarget properly and "jump" around. On the other hand, if I place my two phones very close together and point them at the ImageTarget at roughly the same angle, the cubes do not jump as much.
This leads me to think that the 2 instances of ARCamera fail to realize that they are pointing at the same ImageTarget from 2 different angles, and instead think that the ImageTarget exists in 2 different orientations at the same time.
Is there any way for me to tell Vuforia that I'm using multiple instances of ARCamera pointing at the same ImageTarget? (Or if my hypothesis is completely wrong, how do I actually make a multiplayer AR game?)
Thanks so much in advance!
p.s. I know the Vuforia forums are a better place to ask this question but unfortunately that forum is not particularly active, so I'm trying my luck here.
I've solved the issue by going to the ARCamera gameobject, then in the Vuforia Behavior component, I changed the World Center Mode from DEVICE to FIRST_TARGET. This allows multiple instances of ARCameras to be in different positions.
More info on World Center Mode can be found here.

Unity Particle Collider with Particle

Unity
I create two collider effects and want them can have some function while them collider each other . but i don't know how to make two particle collider.
How to make fire and water can collider each and fire will be put out by water.
Thank for help!!!!
From the documentation (http://docs.unity3d.com/Manual/PartSysCollisionModule.html)
Send Collision Messages : Check this to be able to detect particle
collisions from scripts by the OnParticleCollision function.
Be careful though. Overdoing collisions and particles is a good way to get performance issues
Be sure to follow the tutorials for particle systems too!
https://unity3d.com/learn/tutorials/topics/graphics/particle-system
Thats the best I can currently do, given you have not supplied any work we can comment on.
The unity particle system can collide with colliders(objects) in the scene if collision is enebled for particle system.
But particle systems do not collide with each other. Particles have no volume, so it's not really possible.
You cannot use built-in particle system for fire and water and have them collide with each other. However, you can create a custom particle system using actual objects having colliders which can work as you expect.

AI in different-shaped planets - Unity 3D

I am currently working in a Unity 3D project (in version 5.0.1 to be precise) in which the character can walk in different-shaped planets without falling. So it is always attracted by the planets gravity (similar mechanic to the Super Mario Galaxy games).
Now, the problem is when I try to code the AI for the enemies. This AI should be pretty much simple, but because of this thing that I have with the planets shapes, I haven't been able to come up with a solution. The enemy should check where the player is and move ahead to its position. It's a really dumb enemy. But the thing is, that the enemy must be able to track the player and get to its position no matter what planet he is in. So, if the planet is circular, I cannot make the enemy look at the player and then move forward, as I would do in a plane planet.
I have already tried using a NavMesh, but Unity doesn't want to collaborate and ends up making a NavMesh of 1/3 of the planet. I don't understand why. I have tried changing every single parameter of the NavMesh baking but I haven't succeeded.
Another problem that I would like to do is: ¿How would you make a player be able to walk on the surface of any planet, no matter what its shape, in a smooth way while using a Mesh Collider? I am currently achieving this by getting the planet's normal with a raycast, rotating the player so that the Y axis is perpendicular to the normal and applying a force in -Y to simulate gravity. But this brings lots of problems when I implement the Mesh Collider. It results in a jittery effect. But, when I use a primitive collider from Unity, it works fine...
Anyway. What I need the most now is the answer to the AI question. The other one is kinda like a plus.
P.S: It doesn't matter if the solution is in Javascript. I can then translate it to C# :)

Tile based collision in XNA

I have drawn tiles in my XNA game and loaded my character. My character, however, doesn't move- the map does, which gives it the illusion of movement. Now I am wondering how to actually test against them for collision. I mean, where does the collision code go and how do I make all tiles represent 'one big thing'?
There's a tutorial on pixel based collision detection on XNA Creator's club. You'll need to figure out what objects you want to do collision detection on. I guess you want the character to move across the tiled background, so you don't want to check for collision between your character and the background. Instead you should make any obstacle s sprites and do collision detection on those.
You might have a look at Nick Gravelyn's Tile Engine Tutorials, it goes through the whole process of creating a tile engine. There's a link here to see all the tutorials on YouTube.
You could have a look at the Platformer Starter Kit, it shows how to organize tiles in a map and check for collisions.
Rectangles have a intersects method. If your player is centered and you know the coordinates, loop through the other texture2ds and check for an intersection before scrolling the map.

Categories