,Two Similar Rigidbodies with velocity behaving differently
Hello fellas,
This is my very post here so I apologize in advance for any mistakes or misuse of a tool. I'm new to Unity and am trying to design a very simple game here. For the mechanics, the two key components are a rectangular pad and a cube.
They are both given the same initial velocity of 5f in the z-direction (to the right in the image) Unless I either specify it on code (C#) or a collision with an obstacle occurs, I want the cube to maintain this velocity.
However, it seems like in some frames, its velocity rapidly decays and then comes back to the former velocity (this behaviour can be confirmed via console) and, eventually, the pad reaches the cube and also surpass it.
I've tried to solve this issue via Script Execution Order, exchanging Update with FixedUpdate and vice-versa, adding Physics Materials; all with no luck.
Important to highlight: I'm assuming the difference of functioning is due to the pad being a trigger and the cube is a collider (no "is trigger" marked). But with no friction, no drag nor angular drag, and constantly update via script, I expected the velocity to be constant.
Has anyone had the same issue and found a workaround? Am I missing something?
Answer by UnbreakableOne · Jun 11, 2018 at 09:15 PM
I don't know the answer, just my opinions that might help somehow, hopefully.
I can't test if right now but I'm assuming you're using Kinematic rigidbodies, right?
Do you need to have rigidbodies? Whenever I need complete control over an event, I tend to do the math manually, like collision detection. Maybe you could achieve the same effect without them.
Also does this happen on the builds as well? Maybe an Editor thing?
What about the ground object, maybe it has friction. Did you try applying the same friction-less material to it as well?
I'm sure you've tried testing it in a new project, assuming anything you might've changed in the Physics section would interfere here.
Thank you for your quick reply, I will answer all the topics you lifted. 1. The platform is a $$anonymous$$inematic rigidbody, as I don't want gravity to affect it. The cube and the pad are moving, so I don't understand how I'd use $$anonymous$$inematic here (I always use $$anonymous$$inematics when I want the body to have colliders but keep its position). So, both of them are set to dynamics. The pad, however, has its x and y-axis Freeze Position activated. 2. I think I could do the math manually, but am trying to stick to the Physics Engine. I need at least the cube's rigidbody, because it jumps and falls. I would implement the math myself only in a last resource. 3. Didn't understand what you meant by "builds". The platforms (in 'brown') are fixed, and the backpad is a trigger, so it doesn't "bump" on anything. 4. I tried setting the platform (ground) to 0 static and dynamic friction, 0 static and 1 dynamic friction and vice-versa. No success :/ Currently, none of the objects have physics material. 5. I tested a similar thing with a sphere in a different project and things worked out there. Perhaps due to the different contact surface?
Anyway, thanks for the insights!
Can't seem to breaklines correctly :/ sorry for the mess
I got what you meant by "builds". Just deployed it on a spare android phone I have and the problem persists, although it's perfor$$anonymous$$g (just a visual opinion) a little bit better. On the other hand, both objects keep backtracking a little, looking as they are "correcting" their positions. Still luckless and clueless :/
Your answer
Follow this Question
Related Questions
Rigidbody rotate velocity 0 Answers
Mass effects terminal velocity 1 Answer
i wanna set max velocity, max angular velocity to joint 0 Answers
getComponent().Velocity always returns 0? 2 Answers
Overriding OnCollisionEnter function 2 Answers