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
 

Re: Butterfly Script Question

Previous Thread :: Next Thread 
Majorhappenings is not online. Majorhappenings
Joined: 25 Dec 2013
Total Posts: 299
23 Jan 2017 01:17 PM


I was trying to understand a script from a butterfly model. How does one learn the math behind this stuff below involved with game programming? Basic school trig classes didn't teach this.
I love to script but struggle with math. Any idea's where to learn?





while alive do
game:GetService("RunService").RenderStepped:wait();
local flat, up = Vector3.new(0, 0.1, 0.3), Vector3.new(0, 0.9, 0);
head.CFrame = CFrame.new(
from * flat + from * up,
(2*from - position)*flat + from * up)
* CFrame.Angles(math.pi/2, 0, 0)
* CFrame.Angles(math.pi * -0.1, 0, 0);
from = position;
position = position + Vector3.new(
math.cos(direction) * speed,
(chord(0.4) - 0.5 + chord(5) + chord(7) - 1) * speed,
math.sin(direction) * speed
);
--local facing = ((position - from) * Vector3.new(1, 0, 1)).unit;
--local factor = facing:Dot( (home - position).unit );
local distance = (home - position).magnitude;
local power = 1 - math.exp(-distance ^ 2 / 50);
--factor = -factor * power * 5 + 1;

local rd = Vector3.new(-math.sin(direction), 0, math.cos(direction));
local turn = rd:Dot( (home - position).unit ) * power;

direction = direction + ((chord(2) + chord(4.123) - 1) / 4 + turn / 10) / 2;
--
local h = head.CFrame * CFrame.Angles(math.pi / 2, 0, 0);
local angle = 0.1 + chord(.717/2) * 1 + 0.9 * chord(2.13/2);
local r = 0.2;
local dx = math.cos(angle) * r;
local dy = math.sin(angle) * r;
--
right.CFrame = head.CFrame * CFrame.Angles(-math.pi / 2, 0, 0) * CFrame.new(0, 0, -0.2)
* CFrame.new(-0.04, 0.04, 0)
* CFrame.new(-dx, dy, 0)
* CFrame.Angles(0, 0, -angle)
* CFrame.Angles(3, 0.07, 0)
--
left.CFrame = head.CFrame * CFrame.Angles(-math.pi / 2, 0, 0) * CFrame.new(0, 0, -0.2)
* CFrame.new(0.03, 0.04, 0)
* CFrame.new(dx, dy, 0)
* CFrame.Angles(0, 0, angle)
* CFrame.Angles(0, 0.07, 0)
--
animate();
end
end
Report Abuse
Terminatekill is not online. Terminatekill
Joined: 03 Mar 2016
Total Posts: 54
23 Jan 2017 01:18 PM
Soz don't know how to help
Report Abuse
Majorhappenings is not online. Majorhappenings
Joined: 25 Dec 2013
Total Posts: 299
23 Jan 2017 01:25 PM
Anyone?
Report Abuse
Majorhappenings is not online. Majorhappenings
Joined: 25 Dec 2013
Total Posts: 299
23 Jan 2017 01:53 PM
BUMP
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
23 Jan 2017 01:58 PM
What exactly do you need to know? You just study cframing about you find an algorithm that achieves what you want. Then its just tweaking the values.


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