|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 03 May 2015 01:17 PM |
Interesting, thank you. Does the wait() cause any lag? Are you using a LocalScript for this? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 03 May 2015 01:57 PM |
| ah, should be fine in a LocalScript unless your game is huge |
|
|
| Report Abuse |
|
|