Comments and answers for "arc object's position using sin"
http://answers.unity.com/questions/287189/arc-objects-position-using-sin.html
The latest comments and answers for the question "arc object's position using sin"Comment by JokerMartini on JokerMartini's answer
http://answers.unity.com/comments/289270/view.html
Nothing beats a good nights rest. I read over what you had written a few time and really thought about it and it made complete sense. I got it working perfectly. I post my results here in a bit. Thanks Owen for the patients and help on this.Mon, 23 Jul 2012 23:11:59 GMTJokerMartiniComment by JokerMartini on JokerMartini's answer
http://answers.unity.com/comments/289263/view.html
Alright, I'll check out and see what I can get. I've got the x and z positions working properly. The last part is figuring out the y "arching" position using sin. I'll be looking into the deg2Rad things over the next day or so and I'll let you know how it goes. So far the script does exactly what I want except for the arch. But like you mentioned it currently vibrates about 100 times to fast. I'll be sure to post here the final results once I get it working.Mon, 23 Jul 2012 23:03:33 GMTJokerMartiniComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/288037/view.html
`Mathf.Deg2Rad` is just a single, unchanging number. You don't give it any inputs or anything. You just multiply degrees by it. Look it up in the Unity manual for an example.
Not trying to be obtuse, but I assume you're going to want to fiddle with this more, so need to have done some assembly yourself.Sat, 21 Jul 2012 15:11:16 GMTOwen-ReynoldsComment by JokerMartini on JokerMartini's answer
http://answers.unity.com/comments/287836/view.html
So taking the above function where do I add in, and what do I add in, to make it properly work. I've got everything you said in there except for the radians part. I was unclear how to get that integrated into the function.
Thanks for all your help Owen.Sat, 21 Jul 2012 01:46:09 GMTJokerMartiniComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/287834/view.html
Look up Radians (anywhere, Wikipedia) for some background, then maybe Unity Mathf.
The input to `Mathf.sin` is NOT the angle in degrees. It's the angle in _Radians_. You have to multiply the angle in degrees (`180*time/2`) by `Mathf.Deg2Rad` to convert.
Since a circle has 6.28 radians, using degrees by mistake makes it spin or vibrate about 60 times too fast.Sat, 21 Jul 2012 01:38:59 GMTOwen-ReynoldsComment by JokerMartini on JokerMartini's answer
http://answers.unity.com/comments/287587/view.html
Makes complete sense I've got what you've mentioned mostly implemented. I was hoping you could look over it and help me out. I just don't quite get the arc to happen over the course of 2.0 seconds just right. I got rather lost when you talked about implementing the radians instead of degrees. I was hoping you could take a look at what I have so far and help me figure out what I'm missing. Just copy and paste this snippet below and place it on a sphere or object.
Thanks
#pragma strict
private var stepY = 0.0;
var startTime : float;
var spawnTrgts : GameObject[];
function Start () {
Destroy(gameObject, 2.0);
startTime = Time.time; // Grab the time the shot started
}
function Update () {
var timePassed : float = Time.time - startTime;
stepY = ( Mathf.Abs( Mathf.Sin(180.0*timePassed / 2.0)) * 5.0);
transform.position.y = stepY ;//(2 * Time.deltaTime);
}Fri, 20 Jul 2012 17:33:30 GMTJokerMartiniAnswer by Owen-Reynolds
http://answers.unity.com/answers/287237/view.html
o The math keys of off the angle going from 0 to 180. To get it to take 2 seconds, set the angle to: `180*timePassed/2`. Check: when `timePassed` is 2, 180*2/2 = 180.
o Real trig uses radians, not degrees, so before you use sin you have to convert by multiplying the angle by `Math.DegToRad` (which is really just 2PI/360.)
o To get the time that passed, grab the current time, and count from there:
var startTime : float;
// In Start:
startTime = Time.time; // Grab the time the shot started
// In Update:
var timePassed : float = Time.time - startTime;
The you can use `timePassed` and the 2-second angle in radians in your sin function. Of course, lots of other ways to write the same thing.Fri, 20 Jul 2012 03:36:18 GMTOwen-Reynolds