Setting up a sliding character in the right way - unity3d

I would like to try and make a game similar to Altos Adventure. I am having trouble starting.
How to set up the terrain so that my character doesnt get stuck?
I simply drew a test sprite for the ground in photoshop. What collider2d should I use?
I use polygon collider and reduce friction in the material. But the character gets stuck, hits small invisible bumbs and it feels awful. The worst part is connecting 2 ground sprites together! The point where they connect is always messy.
I have a question for the future as well. How would I add the endless part of the game?
Would having many "pieces" set up and just spawning them as the player rides down work?
I havent written any code yet as the problem is simply in the physics in my opinion.
Thanks to anyone who takes the time and tries to help!

To move your player use rigid body.AddForce(Vector3 direction, ForceMode forceMode); then create a Physics Material with friction = 0 and put it in your player's collider.

Related

Objects not colliding Unity2D

I am trying to make a Retro Tenis Game in Unity2D but I have some issues with the colliding system.
My controller does not collide with the walls. It goes through them.
It should stop in the wall like pic1 but it goes through it like pic2.
Can anyone help me, please?
pic1
pic2
UPDATE#1: I added a RigidBody component but it does not fix it. (pic3)
pic3
You shouldn't use the colliding system for this purpose. It would be much better that the script in charge of moving your paddle was able to control its maximum and minimum height too (note that the screen size can change, and the paddles should move at different heights depending on the screen size).
Although if you want to do it with the collision system and "walls" that limit the space of the paddles, both the "walls" and the paddles need to have a correctly positioned BoxCollider2D and the paddles an extra kinematic Rigidbody2D too (as they can move).
Also make sure to move the paddles using physics and not modifying its position with transform.position (see Rigidbody2D.MovePosition)
Edit: Unity2D physics system is rather a complicated topic and difficult to get it well on your own. I'd suggest to learn the basics in the Unity Learning Platform. You could start with this project.
You need add RigidBody2D to your "circle"

Unity3d - Player flips after a specific chunk

So, I've made a very simple game, which all you basically do is glide through the terrain and avoid the obstacles (I haven't implemented obstacles yet). And I've encountered a very strange problem. When ever I hit the fifth chunk, the player starts to flip:
Can anybody help me find what the problem is and how can I fix it?
Edit: I solved it by using creating a physics material with 0 friction annd applied it to both the chunk and the player.
This could be an issue with your colliders being just a tad too big. check the dimensions of your player's box collider and see if it is bigger than your player. If so make it fit to just inside the outer edges of the player box. Also, unless you ever plan to flip the player intentionally, You could always just apply a constant downward force (Rigidbody + gravity usually will suffice) to keep this from happening. Hope that helps!

Unity3D Ball physics bug in BlockBreaker game 2D

I am trying to create a block breaker game in Unity 3D but I am having problems (this is my first time creating a game). When I throw the ball it ends like this https://gfycat.com/LimitedVagueAnkole. The physics between the ball and the bricks should be problematic i think but I don't know why. My ball's material is frictionless and its bounciness is 1. My bricks materials are None (physics material).
I can send more info if it helps but I don't really know what else to send.
PS: I didn't code the breaking of the bricks yet. I just don't understand why the ball isn't acting the way it should.
The same thing is happening to me, I think I have a solution for this problem. I think the reason why the ball keeps bouncing at one place is because the ball didn't have much speed to escape from the loop. Try increasing the speed of the ball a bit and you could see the ball indeed escape bouncing at one particular angle.

swift usesPreciseCollisionDetection does not work?

i have made an app where you need to shoot on an enemy but sometimes the bullet goes through the enemy. swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this?
so i added usesPreciseCollisionDetection = true.
but the bullet sometimes still goes trough the enemy. so my question was did i do something wrong or is usesPreciseCollisionDetection not working?
thank you for reading my question I hope someone can help me.
You are using moveTo to move your bullets, Physics Engine does not work with moveTo the way you want it to, usesPreciseCollisionDetection will not do anything
As far as your Physics World is concerned, your bullet is stationary. You are just playing God and performing some kind of molecular transportation to move items.
You need to use functions like applyImpulse or even just give the physicsBody a velocity if you want this to work correctly
I had similar problem that is collision was sometimes not detected even when usesPreciseCollisionDetection was set to true and both SKPhysicsBody were rectangles. In my case usesPreciseCollisionDetection for some reason started working much better when I changed one of the SKPhysicsBody to circle instead of rectangle. Try changing your bullet physics body to circle, it seems that collision detection algorithm with circles is more precise so that might help you.

Side scroller style scene with gravity

I've started learning sprite kit and I think I've got the basics but now I'm struggling with something.
I want to create a game that has a 'Streets of rage' type feel to it whereby the user can move up and down, but isn't jumping, they're still on a 2D plane. But I also want them to be effected by gravity e.g stairs etc. like the following picture.
Am I right in assuming that I should have my background image with colliders around the blue and brown edges, and then create a physicsbody collider located at the feet of my player/players so that it looks like they can move against the background, but when their feet reach the top it would stop?
Could I then place other obstacles like rocks etc on that path that they would be able to collide into, but that could also sit over the path and the sky? How would I handle the fact that these could be constantly colliding depending on the position?
I appreciate there isn't any code here, but I'm trying to understand the concept around this before I jump in coding a solution.
Thanks
I would use a categoryBitMask to separate the different planes of objects.
And I would play with collisionBitMask/contactTestBitMask depending from the plane the player is in, in addition to the z-order.
Thus you can have a rock that collides your player if they are both in the same line else the player would walk behind/front.