Skip to content

Commit 7d27e3e

Browse files
committed
Serlialized Fields !
1 parent ea41446 commit 7d27e3e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Assets/Level 1.unity

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ Prefab:
193193
propertyPath: m_RootOrder
194194
value: 1
195195
objectReference: {fileID: 0}
196+
- target: {fileID: 54398052497140864, guid: 30da5df0ee3ec8247ac02c74ea8e0a34,
197+
type: 2}
198+
propertyPath: m_Constraints
199+
value: 8
200+
objectReference: {fileID: 0}
196201
m_RemovedComponents: []
197202
m_ParentPrefab: {fileID: 100100000, guid: 30da5df0ee3ec8247ac02c74ea8e0a34, type: 2}
198203
m_IsPrefabParent: 0

Assets/Rocket Ship.prefab

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ Rigidbody:
341341
m_PrefabInternal: {fileID: 100100000}
342342
m_GameObject: {fileID: 1839490939624924}
343343
serializedVersion: 2
344-
m_Mass: 0.12
345-
m_Drag: 0.25
346-
m_AngularDrag: 0.06
344+
m_Mass: 1
345+
m_Drag: 0.2
346+
m_AngularDrag: 0.05
347347
m_UseGravity: 1
348348
m_IsKinematic: 0
349349
m_Interpolate: 0
@@ -488,3 +488,5 @@ MonoBehaviour:
488488
m_Script: {fileID: 11500000, guid: 74e47f00f5249b64b8cb52acb8272110, type: 3}
489489
m_Name:
490490
m_EditorClassIdentifier:
491+
rcsThrust: 250
492+
mainThrust: 50

Assets/Rocket.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
public class Rocket : MonoBehaviour {
77

8+
[SerializeField] [Range(1.0f, 1000f)] float rcsThrust = 1;
9+
[SerializeField] [Range(1.0f, 1000f)] float mainThrust = 1;
10+
811
Rigidbody rigidbody;
912
AudioSource audioSource;
1013

@@ -26,7 +29,7 @@ private void Thrust()
2629
{
2730
if (Input.GetKey(KeyCode.Space))
2831
{
29-
rigidbody.AddRelativeForce(Vector3.up);
32+
rigidbody.AddRelativeForce(Vector3.up * Time.deltaTime * mainThrust);
3033
if (!audioSource.isPlaying)
3134
{
3235
audioSource.Play();
@@ -44,11 +47,11 @@ private void Rotate()
4447
rigidbody.freezeRotation = true; // Take manual control of the rotation
4548
if (Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
4649
{
47-
transform.Rotate(new Vector3(0,0,50) * Time.deltaTime);
50+
transform.Rotate(Vector3.forward * Time.deltaTime * rcsThrust);
4851
}
4952
if (Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.A))
5053
{
51-
transform.Rotate(new Vector3(0, 0, -50) * Time.deltaTime);
54+
transform.Rotate(-Vector3.forward * Time.deltaTime * rcsThrust);
5255
}
5356
rigidbody.freezeRotation = false; // Resume Physics Control of rotation
5457
}

0 commit comments

Comments
 (0)