Commit e93f0ac7 authored by Hugo Rivera's avatar Hugo Rivera

Improve orbit.

parent bbd94a23
......@@ -138,8 +138,8 @@ Camera:
m_GameObject: {fileID: 156497488}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_ClearFlags: 2
m_BackGroundColor: {r: 0.06325692, g: 0.090127595, b: 0.13235295, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
......@@ -171,7 +171,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 156497488}
m_LocalRotation: {x: -0.1068719, y: -0.84011364, z: 0.063013725, w: 0.5280311}
m_LocalPosition: {x: 11.63, y: 0.09, z: -0.01}
m_LocalPosition: {x: 18.74, y: 0.69, z: 6.32}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: -0.39600003, y: -115.604004, z: 13.943001}
m_Children: []
......@@ -251,7 +251,6 @@ GameObject:
- 33: {fileID: 1057224804}
- 135: {fileID: 1057224803}
- 23: {fileID: 1057224802}
- 54: {fileID: 1057224801}
- 114: {fileID: 1057224800}
m_Layer: 0
m_Name: Moon
......@@ -272,23 +271,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
thrust: 0
rb: {fileID: 0}
earth: {fileID: 0}
--- !u!54 &1057224801
Rigidbody:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1057224799}
serializedVersion: 2
m_Mass: 10
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
velocity: {x: 0, y: 0, z: 0}
earth: {fileID: 2012200227}
camera: {fileID: 156497488}
--- !u!23 &1057224802
MeshRenderer:
m_ObjectHideFlags: 0
......@@ -344,7 +329,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1057224799}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.0239325, y: -0.0000019073486, z: -1.0086894}
m_LocalPosition: {x: 9, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
......@@ -361,7 +346,6 @@ GameObject:
- 33: {fileID: 2012200230}
- 135: {fileID: 2012200229}
- 23: {fileID: 2012200228}
- 54: {fileID: 2012200232}
m_Layer: 0
m_Name: Earth
m_TagString: Untagged
......@@ -424,24 +408,9 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2012200227}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.0239325, y: -0.11, z: -6.77}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 4, y: 4, z: 4}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
--- !u!54 &2012200232
Rigidbody:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2012200227}
serializedVersion: 2
m_Mass: 1000
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
......@@ -4,17 +4,20 @@ using System.Collections;
public class Orbit : MonoBehaviour
{
public float thrust;
public Rigidbody rb;
public Vector3 velocity;
public GameObject earth;
public GameObject camera;
void Start()
void Start()
{
rb = GetComponent<Rigidbody>();
earth = GameObject.Find("Earth");
velocity = new Vector3(0, 0, 0);
}
void FixedUpdate()
{
rb.AddForce(10 * (Quaternion.Euler(0, 0, 90) * (earth.transform.position + transform.position)));
velocity = Quaternion.Euler(0, 90, 0) * (earth.transform.position - transform.position);
velocity.Normalize();
transform.position += velocity * 20 * Time.deltaTime;
camera.transform.LookAt(transform);
}
}
\ No newline at end of file
No preview for this file type
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment