- Home /
how to freeze a rigidbody onto of another?
hey guys, I am trying to make a 2d breakout sort of spin off and I want to add a little tweak to the gameplay, what I want to add is overtime the ball comes back into contact with the paddle the ball sticks to the paddle, so then you have to click again to fire the ball off again? I am so unsure of how to do it, could someone please show me a code example or explain how I would do this please?
Answer by IronPig_ · Jul 03, 2017 at 12:15 PM
You should check when they are in contact with OnCollisionEnter2D and if they are you should set the ball's rigidbody 2D to be kinematic and set the paddle to be its parent than when you want to fire it you should unparent it and set it's rigidbody 2D to nonkinematic and apply a force to it.
thank you for replying and that is somewhat helping, but it still doesn't stick to the paddle? its setting it to kinematic as it hits it but still bouncing around
sorry to waste your time, but I figured it out! but thank you so much for your help! (:
hey pigletsoft, sorry to bother you again but I have another question I have it all working very well, but sometimes now when the ball collides with the side of the paddle it still sticks? how could I make it so that enters the game over scene?
I have a collider below the paddle so if the ball goes past the paddle it will touch it and be game over, should I just bring that collider up closer to the paddle so it triggers the game over without attaching to the side? or would there be a good code trick I could use?
or at least ins$$anonymous$$d of triggering the game over when it hits the side, it just doesn't stick to the paddle then bounces into the game over collider? I think that would be a cool way to do it but I am unsure how?
Your answer
Follow this Question
Related Questions
Multiplying score on a gameobject destroy; only while a button is held 0 Answers
How to fix graphic bugs LoadScene? 0 Answers
im trying to do an immortal state when my player take damage 2 Answers
2D Game Trail renderer 0 Answers
Unity - dragging a RigidBody2D Gameobject by mouse/touch without any lag 0 Answers