예제 #1
0
파일: Body.cs 프로젝트: Kirme/solar-system
    private void CalcVelocity(Vector3 force)
    {
        acceleration  = force / mass;               //Acceleration in m/s^2
        acceleration /= scaleManager.GetDistance(); //Acceleration in AU*s^-2

        velocity += acceleration * Time.fixedDeltaTime * scaleManager.GetTime();
    }
예제 #2
0
    private void Start()
    {
        lastX = this.transform.position.x;
        float axisLength = (orbitAround.transform.position - this.transform.position).magnitude * scaleManager.GetDistance(); //Axis length in m

        //Equation: sqrt(G*M/r)
        localVelocity = Mathf.Sqrt(scaleManager.GetG() * orbitAround.GetComponent <Body>().GetMass() / axisLength) * velocityMultiplier; //Velocity in m/s
        //Debug.Log(localVelocity);
        localVelocity /= scaleManager.GetDistance();                                                                                     //Velocity in AU/s
        velocity       = localVelocity * transform.forward;
    }