- Home /
Problem is not reproducible or outdated
Smooth material of cylinders
Hi, I'm new to Unity and I'm trying to develop an air hockey game. I've been focusing on the physics and I've got a problem: When the Player collides the puck, in some way the puck gets "linked/anchored/catched" by the Player unless the corner between the Player and the puck is not high. If I do not freeze the Y axys, then it's way smoother, but not enough for me. (And I don't want the puck to keep rotating too!). Both Player and puck are cylinders and I would like to make rotation more fluent, just like if the material is smoothened. (Already played with drag and friction)
Any concrete help will be really appreciated!
Screenshot: http://s11.postimage.org/7b4fce9ht/Senza_titolo_2.jpg
By "it's way smoother" do you mean that it "sticks" a lot less, but still seems caught for a moment?
Are you moving the player using physics (setting velocity or using AddForce) or are you just setting position of the player?
Does the bug happen when the puck hits a non-moving player, or only when the player moves quickly into the puck?
Yes, it's like the surface is gummy ins$$anonymous$$d of icy anyway. I'm moving the player using AddForce. The bug happens when the player touches the puck: ins$$anonymous$$d of sliding away, the puck is catched by the player, rounds for 1/4 of the Player cylinder and goes away. It's a bit difficult to explain by words.
Answer by sparkzbarca · Dec 10, 2012 at 04:30 PM
is your player a mesh?
If so check the smooth sphere collisions. That will smooth out the collisions with spheres (or in this case sphere like objects)
Answer by Owen-Reynolds · Dec 12, 2012 at 03:50 AM
Maybe check the contact area of the capsules. They should be hitting straight-edge to straight-edge, as if they were cylinders. If the puck hits the player where it starts to dip into the ground, physics will try to force the puck downwards. For me, it just loses a lot of speed, but your set-up could be trapping the puck down there.
To line them up, you can not have a floor (if everything has Y locked.) Or set the floor and player layers not to interact (so the player collider can hang through the floor, presenting a nice vertical edge for the puck.)
A capsule collider, like you're using, is going to give the smoothest performance. It uses exact math to give two round things bouncing off each other, and runs faster than a mesh collider.
Are you using a physics material? That can help with a stronger bounce effect.
Hi, the problem is that I need gravity to work (to make both player and ball stop). Anyway I made a test without the field and the gravity but the behaviour was the same. The bounciness is not what I'm looking for, because it's enabled only when the puck and the player enter collision and not during collision.
Gravity makes it stop because of friction with the ground? That can also be done with code (set drag, and stop when `velocity.sqr$$anonymous$$ag<0.3ish`.)
I'd keep testing by removing things, like maybe some stuff in the script. Normal collisions don't stick like that. Eventually you'll change/remove one thing and the sticking will go away. Or restart. It will bounce normally. Then add things back until it sticks.