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 » Scripters
Home Search
 

Graph Math

Previous Thread :: Next Thread 
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
03 May 2015 11:43 AM
I am trying to create a realistic weapon bob for first person. I plan on using a loop to apply changes to the ToolGrip property of whichever gun is equipped. To do this I would need an equation to run through the loop of course. I thought about it and decided that a figure 8 type of graph would be best. Here are the possible equations for that:


Cartesian equation:

x⁴ = a²(x²-y²)

Polar equation:

r² = a²cos(2θ)sec⁴(θ)


I would probably put the Cartesian equation into a y= form, but I'm not sure if this method would be best. Of course I could change "a" to whichever number to "bend" the graph, but I still wonder if a figure 8 is even all that realistic. Any suggestions? Is this the best method?
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
03 May 2015 11:58 AM
Bump, suggestions?
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
03 May 2015 01:09 PM
I decided to go with a parabola and sine instead. Turned better than I thought. If anyone wants to reference:

local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local torso = character:WaitForChild("Torso")
local equipped = false

tool.Unequipped:connect(function()
equipped = false
end)

tool.Equipped:connect(function()
equipped = true
end)

local speed = 8
local bounceY = -.1
local bounceX = .1

while wait() do
if equipped and torso.Velocity.magnitude > 0 then
repeat
local x = math.sin(speed*time())
local equation = math.pow(x, 2)
print(equation)
tool.GripPos = Vector3.new(0, -equation*bounceY, x*bounceX)
wait()
until not equipped or torso.Velocity.magnitude <= 0
end
end
Report Abuse
logarhythm is not online. logarhythm
Joined: 23 Dec 2008
Total Posts: 10267
03 May 2015 01:17 PM
Interesting, thank you.
Does the wait() cause any lag? Are you using a LocalScript for this?
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
03 May 2015 01:33 PM
This isn't anything all that real. Just a plain script in a tool with a handle. Could possibly lag in a really big game and would need FilteringEnabled editing most likely. But it's a start. Something to work with. Thought I'd share my own solution.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
03 May 2015 01:35 PM
*Local script, my bad
Report Abuse
logarhythm is not online. logarhythm
Joined: 23 Dec 2008
Total Posts: 10267
03 May 2015 01:57 PM
ah, should be fine in a LocalScript unless your game is huge
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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