generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Multi Pong Physics?

Previous Thread :: Next Thread 
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
11 Jun 2014 08:24 AM
Thats it? Wow! I thought it would have some complex math equation or something lol.
Report Abuse
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
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
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
12 Jun 2014 05:03 PM
Bump
Report Abuse
cntkillme is not online. 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
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
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 is not online. 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 is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
12 Jun 2014 05:26 PM
Velocity = -Velocity
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
12 Jun 2014 05:30 PM
Is this for Parts or GUI?
Report Abuse
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
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 is not online. 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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
12 Jun 2014 07:50 PM
gui hit detection is hard to do
Report Abuse
cntkillme is not online. 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 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
26 Jun 2014 01:42 PM
Sorry for not responding sooner, but thanks a ton! It works now!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image