I have a problem with physics. I'm trying to do something and I do not know if this is possible in Unity2D.
In the picture you see what I want to do. I want that circle to get into that cone.
The problem is that if I put in a collider circle it collides with the cone. That's why I wonder if there is any way to do this without 3D elements.
Related
I'm trying to create a platform game, watching videos and tutorials I see that they use the Tile Palette option very frequently.
When creating the 2D Tilemap Collider, each square has its collider, and I guess that makes it consume a lot of resources, so to solve that I create a 2D Composite collider.
The problem is when the player collides with the collider of a vertical wall, causing the player's rigidBody.velocity.y to add force and that doesn't allow me to execute the jump.
https://clipchamp.com/watch/nFKCJOv7DEX
Here you can see under the scene of the game the debug.log that ends up showing me a speed to the Y axis
This project would be for android, and I would like to optimize it as much as possible. Do you have any idea so that in that collision I do not add force Y?
I have tried to change the speed in an onColliderStay2d and put the vertical tilemaps with another tag to differentiate them from the ground, but nothing.
Instead of checking your y velocity to see if you are grounded or not I recommend just making a rectangular area under your player character and check if it overlaps with the ground using Physics2D.OverlapArea. It's way less error prone.
Also, just because composite collider creates less shapes than tilemap collider doesn't mean it is less performant, the physics system doesn't iterate them one by one. Do yourself a favor and just use the tilemap collider instead.
My question is quite simple. How do I make a cube which has other game objects inside of it, and can detect when those objects collide with sides of the cube. I can just use a collider for each of the sides but I want to be able to shrink and grow the cube while the program is running. If I used a collider for each of the sides I would have to move each of them individually. Is there a way to use just one collider on the cube?
Place six flat cubes around with a thin collier box and then make parent them to an empty game object.
Im writing a simple mini golf game in 2D. Right now im simply vertically dropping ball into the hole which has Polygon Collider of 'U' shape and is placed on tilemap that has Tilemap Collider. I want the hole collider to overlay the tilemap collider but not turning them off, because tiles and hole have different size and if im gonna shoot ball from start position and it gonna land on tile that collider is turned off because its touching hole - ball will go thru it into the depths of hell.
I have tried to put both hole_object and tilemap in different layers but it doesnt work. Even if hole is slightly over tilemap ball will stop on the ground (tilemap). Ive seen solutions like turning one collider if the second one notice collision but hole collider is like i said, in 'U' shape so tilemap collider will be always first to notice ball, which means it wont let ball go thru him into the hole.
I expect the ball_object to collide only with objects and tiles that are in the highest layers instead of all of them.
I have 2 GameObjects, the first one is on a 2D interface (plane), and the second one is a 3D character (also sitting on a plane), so the 2D texture represents the 3D character in the game,
I want to drag the 2D texture and have the 3D character move with it, but I want it to be proportional, for example if the 2D texture reached half of its plane the 3D character must be as well at same position accordingly, and the 2 planes are not equal as well (width-height), for example 2D plane is 2x3 and 3D plane is 9x5,
Can anyone please help doing this ?
PS: I am using NGUI to draw my 2D interface
I think i understand your question.
You might want to make a class that scales all the movements.
(I do this when making GUI's so that screen size doesnt matter)
XofPlayer = (Xof2d/widthof2d)*widthof3d
Does this make sense? IF you have the size of the 2d plane and an object get to half way on that plane. The player will then also be halfway on their plane. No matter what the two sizes are. You would do the same thing with the Z axis for depth. And I guess Y if you need it.
This is the setup I have. I am trying to make a game in unity which appears 2d but is actually 3d. I have a simple sphere and a floor, which is made up of cubes placed next to each other(the colliders overlap a little) with the same Y value and Z value. My 2d plane is in X-Y plane(Z being the depth).
Now in the script attached to the sphere, in the Update function, I have used rigidbody.addForce() in the +ve X axis function to move the sphere forward. I have attached rigidbody to the sphere and enabled gravity. The collider of the sphere is the default one.
Now the problem is:
When I run this scene. The sphere moves forward but at the intersection of the colliders, it jumps a bit(very less but still noticable) upward and loses its momentum. It happens at every intersection.
BUT this does NOT happen if I place the sphere on a floor made up of a SINGLE cube(a very long one).
Is this problem arising because of overlapping colliders? How do I solve this issue?
Thanks in advance
I don't think this is fixable. Unity physics is approximate, and even when physics material are set up to 1.0 bounciness, momentum doesn't stay constant — I learned it the hard way when I tried to develop a game depending on constant momentum, and had to write my own little physics simulation for that.