|
| 10 Jun 2014 08:53 PM |
| Does anyone know how you could create physics like in the ROBLOX game Multi Pong where the ball bounces on blocks but doesn't slow down/increase in speed? Thanks! |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2014 08:55 PM |
| Just invert the velocity based on the positional offset of the ball. Hits on the left/right, invert X. Hits on the top/bottom, invert Y. Corners will take care of themselves and invert both X/Y. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2014 08:24 AM |
| Thats it? Wow! I thought it would have some complex math equation or something lol. |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2014 01:32 PM |
| Im still a bit lost, sorry lol. Could you give me some sample code I could work with? |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jun 2014 05:06 PM |
Just do -vector3
Since z is 0 anyways, it shouldn't affect z |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2014 05:21 PM |
Ok now Im totally confused. I thought I would change the X and Z, but not Y, since it doesn't move along the Y axis?
Can someone please give me an example in code, it would help me a ton! |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jun 2014 05:24 PM |
| Well the Y component of velocity (if that is what you are using) should just be 0, so the above should still work. |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
| |
|
| |
|
|
| 12 Jun 2014 07:40 PM |
| Parts, using BodyVelocity (not the Velocity property, as that gets slower over time and would make the ball stuck lol). |
|
|
| Report Abuse |
|
|
enzo90
|
  |
| Joined: 25 Mar 2012 |
| Total Posts: 7104 |
|
|
| 12 Jun 2014 07:42 PM |
| Speaking of GUI...how would you do it for GUI? |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2014 07:50 PM |
| gui hit detection is hard to do |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jun 2014 07:51 PM |
| It's not hard, but the velocity part will be hard. |
|
|
| Report Abuse |
|
|
enzo90
|
  |
| Joined: 25 Mar 2012 |
| Total Posts: 7104 |
|
|
| 12 Jun 2014 08:06 PM |
| I feel like scripting is my summer math program.:3 |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2014 08:52 PM |
local PongBall = workspace.PONG local JustDidIt = false
PongBall.Touched:connect(function(TheToucher) if JustDidIt then return end JustDidIt = true local diff = TheToucher.Position - PongBall.Position local vzf = math.abs(diff.X) >= TheToucher.Size.X/2 + PongBall.Size.X/2 and -1 or 1 local vxf = math.abs(diff.Z) >= TheToucher.Size.Z/2 + PongBall.Size.Z/2 and -1 or 1 PingBall.BodyVelocity.velocity = PongBall.BodyVelocity.velocity * Vector3.new(vzf, vxf) wait() JustDidIt = false end)
Try that. |
|
|
| Report Abuse |
|
|
|
| 26 Jun 2014 01:42 PM |
| Sorry for not responding sooner, but thanks a ton! It works now! |
|
|
| Report Abuse |
|
|