简体   繁体   中英

Unity breakout game change direction of ball based on which part of the paddle it made with collision using c#

I am experimenting with a 2D breakout game (in c#) using Unity 5 and wanted to know how I can change the direction of the ball based on which part of the paddle it made collision with.

For example if the ball touched the left part of the paddle then the ball should go left and if it struck the middle then it should go straight up and if it struck the right side then go right.

您可以在桨的每一侧上制作4个不同的盒子碰撞器2d作为子对象,并向它们添加OnCollisionEnter2d()方法,以在其中应用您的机制

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM