Add rotation
This commit is contained in:
@@ -331,7 +331,7 @@ Camera:
|
|||||||
height: 1
|
height: 1
|
||||||
near clip plane: 0.3
|
near clip plane: 0.3
|
||||||
far clip plane: 1000
|
far clip plane: 1000
|
||||||
field of view: 60
|
field of view: 48.4
|
||||||
orthographic: 0
|
orthographic: 0
|
||||||
orthographic size: 5
|
orthographic size: 5
|
||||||
m_Depth: 0
|
m_Depth: 0
|
||||||
@@ -356,13 +356,13 @@ Transform:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 311524101}
|
m_GameObject: {fileID: 311524101}
|
||||||
m_LocalRotation: {x: 0.1227878, y: -0.6963643, z: 0.1227878, w: 0.6963643}
|
m_LocalRotation: {x: 0.11670625, y: -0.6974093, z: 0.11670625, w: 0.6974093}
|
||||||
m_LocalPosition: {x: 1.09, y: 0.8, z: 0.05}
|
m_LocalPosition: {x: 1.318, y: 0.836, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1244011693}
|
m_Father: {fileID: 1244011693}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 20, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 19, y: -90, z: 0}
|
||||||
--- !u!1001 &466409623
|
--- !u!1001 &466409623
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -842,6 +842,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
speed: 5
|
speed: 5
|
||||||
gravity: -9.81
|
gravity: -9.81
|
||||||
|
jumpSpeed: 8
|
||||||
velocity: {x: 0, y: 0, z: 0}
|
velocity: {x: 0, y: 0, z: 0}
|
||||||
drag: {x: 0.1, y: 0.1, z: 0.1}
|
drag: {x: 0.1, y: 0.1, z: 0.1}
|
||||||
--- !u!143 &1244011689
|
--- !u!143 &1244011689
|
||||||
@@ -859,7 +860,7 @@ CharacterController:
|
|||||||
m_Radius: 0.390984
|
m_Radius: 0.390984
|
||||||
m_SlopeLimit: 45
|
m_SlopeLimit: 45
|
||||||
m_StepOffset: 0.3
|
m_StepOffset: 0.3
|
||||||
m_SkinWidth: 0.26
|
m_SkinWidth: 0.06
|
||||||
m_MinMoveDistance: 0.001
|
m_MinMoveDistance: 0.001
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!4 &1244011693 stripped
|
--- !u!4 &1244011693 stripped
|
||||||
@@ -867,23 +868,6 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 736482141215372739, guid: 94c015d94f6e5364e9b36b960bbe1b77, type: 3}
|
m_CorrespondingSourceObject: {fileID: 736482141215372739, guid: 94c015d94f6e5364e9b36b960bbe1b77, type: 3}
|
||||||
m_PrefabInstance: {fileID: 1244011686}
|
m_PrefabInstance: {fileID: 1244011686}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1818360609 &1244011694
|
|
||||||
RotationConstraint:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1244011687}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_Weight: 1
|
|
||||||
m_RotationAtRest: {x: 0, y: 0, z: 0}
|
|
||||||
m_RotationOffset: {x: 0, y: 0, z: 0}
|
|
||||||
m_AffectRotationX: 1
|
|
||||||
m_AffectRotationY: 1
|
|
||||||
m_AffectRotationZ: 1
|
|
||||||
m_IsContraintActive: 1
|
|
||||||
m_IsLocked: 1
|
|
||||||
m_Sources: []
|
|
||||||
--- !u!1001 &1367772466
|
--- !u!1001 &1367772466
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class FishController : MonoBehaviour
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
float moveX = Input.GetAxisRaw("Horizontal");
|
float moveX = 0 - Input.GetAxisRaw("Vertical");
|
||||||
float moveZ = Input.GetAxisRaw("Vertical");
|
float moveZ = Input.GetAxisRaw("Horizontal");
|
||||||
float moveGravity = gravity * Time.deltaTime;
|
float moveGravity = gravity * Time.deltaTime;
|
||||||
|
|
||||||
if (controller.isGrounded && velocity.y < 0)
|
if (controller.isGrounded && velocity.y < 0)
|
||||||
@@ -37,9 +37,11 @@ public class FishController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
velocity.x = moveX * speed;
|
velocity.x = moveX * speed;
|
||||||
velocity.z = moveZ * speed;
|
// velocity.z = moveZ * speed;
|
||||||
velocity.y += moveGravity;
|
velocity.y += moveGravity;
|
||||||
|
|
||||||
|
transform.Rotate(0, moveZ, 0);
|
||||||
|
|
||||||
Vector3 moveVelocity = velocity * Time.deltaTime;
|
Vector3 moveVelocity = velocity * Time.deltaTime;
|
||||||
|
|
||||||
if (moveVelocity.y < 0 && Math.Abs(moveVelocity.y) < controller.minMoveDistance)
|
if (moveVelocity.y < 0 && Math.Abs(moveVelocity.y) < controller.minMoveDistance)
|
||||||
@@ -47,6 +49,6 @@ public class FishController : MonoBehaviour
|
|||||||
moveVelocity.y = (gravity * 0.1f) * Time.deltaTime;
|
moveVelocity.y = (gravity * 0.1f) * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.Move(moveVelocity);
|
controller.Move(transform.rotation * moveVelocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user