Browse Source

added HorseBall

master
Joshua Reason 4 years ago
parent
commit
f2dc9216bb
9 changed files with 395 additions and 35 deletions
  1. +30
    -0
      Assets/Input/HerdInput.inputactions
  2. +108
    -2
      Assets/Scenes/CaseyTest.unity
  3. +17
    -12
      Assets/Scenes/SampleScene 1.unity
  4. +3
    -3
      Assets/Scripts/HammerController.cs
  5. +93
    -11
      Assets/Scripts/Input/BallController.cs
  6. +48
    -4
      Assets/Scripts/Input/HerdController.cs
  7. +6
    -3
      Assets/Scripts/Input/PlayerController.cs
  8. +83
    -0
      Assets/WorldAssets/Prefabs/HorseBall.prefab
  9. +7
    -0
      Assets/WorldAssets/Prefabs/HorseBall.prefab.meta

+ 30
- 0
Assets/Input/HerdInput.inputactions View File

@ -12,6 +12,14 @@
"expectedControlType": "Vector2", "expectedControlType": "Vector2",
"processors": "", "processors": "",
"interactions": "" "interactions": ""
},
{
"name": "Sprint",
"type": "Value",
"id": "5ff5a253-6b95-490a-951c-f71399a76bbc",
"expectedControlType": "",
"processors": "",
"interactions": ""
} }
], ],
"bindings": [ "bindings": [
@ -135,6 +143,28 @@
"action": "Movement", "action": "Movement",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
},
{
"name": "",
"id": "10cbf5c8-8c98-4092-aa44-a05f2ee31a17",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "",
"action": "Sprint",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e2708d8c-53ab-4bb3-9344-e8f146416905",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Sprint",
"isComposite": false,
"isPartOfComposite": false
} }
] ]
} }

+ 108
- 2
Assets/Scenes/CaseyTest.unity View File

@ -259,8 +259,8 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 101379897} m_GameObject: {fileID: 101379897}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -131.4, y: -53, z: 13.56534}
m_LocalScale: {x: 1746.2621, y: 37.181408, z: 2115.8079}
m_LocalPosition: {x: -131.4, y: -193, z: -1871}
m_LocalScale: {x: 6079.9604, y: 129.4545, z: 7366.608}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
@ -455,9 +455,30 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3} m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
EatHorse: 0
HorseCount: 0 HorseCount: 0
size: 0 size: 0
horsePrefab: {fileID: 0} horsePrefab: {fileID: 0}
herd: {fileID: 0}
Speed: 10
--- !u!114 &680610894 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8253619032045175704, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
m_PrefabInstance: {fileID: 983308776}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &680610897 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
m_PrefabInstance: {fileID: 983308776}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &695221452 --- !u!1001 &695221452
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1189,6 +1210,85 @@ MonoBehaviour:
target: {fileID: 984142341} target: {fileID: 984142341}
camHeight: 50 camHeight: 50
Clamp: {x: 12, y: 100} Clamp: {x: 12, y: 100}
--- !u!1001 &983308776
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1457452761}
m_Modifications:
- target: {fileID: 5790973319256092316, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_IsKinematic
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175704, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: Speed
value: 10
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175705, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_Name
value: HorseBall
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalPosition.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalPosition.z
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8253619032045175711, guid: d019eaad4f87842448d362a485c2990b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d019eaad4f87842448d362a485c2990b, type: 3}
--- !u!1 &984142341 --- !u!1 &984142341
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1505,7 +1605,9 @@ MonoBehaviour:
SpawnPoint: {fileID: 0} SpawnPoint: {fileID: 0}
WaitTime: 0.15 WaitTime: 0.15
Centre: {fileID: 984142342} Centre: {fileID: 984142342}
Herd: []
GameState: {fileID: 0} GameState: {fileID: 0}
Ball: {fileID: 680610894}
--- !u!4 &1457452761 --- !u!4 &1457452761
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1519,6 +1621,7 @@ Transform:
m_Children: m_Children:
- {fileID: 984142342} - {fileID: 984142342}
- {fileID: 2009130164} - {fileID: 2009130164}
- {fileID: 680610897}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1869,10 +1972,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3} m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
EatHorse: 0
HorseCount: 1000 HorseCount: 1000
size: 10 size: 10
horsePrefab: {fileID: -927199367670048503, guid: 707f698da07e87f4ab470faa7ed70d74, horsePrefab: {fileID: -927199367670048503, guid: 707f698da07e87f4ab470faa7ed70d74,
type: 3} type: 3}
herd: {fileID: 0}
Speed: 10
--- !u!54 &1853754229 --- !u!54 &1853754229
Rigidbody: Rigidbody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

+ 17
- 12
Assets/Scenes/SampleScene 1.unity View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994} m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@ -476,22 +476,22 @@ PrefabInstance:
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0.7313702
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: -0
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
value: -0.68198067
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
value: 265.997
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
@ -508,10 +508,15 @@ PrefabInstance:
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 17.33 value: 17.33
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -6057495791831066277, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 77.66
value: 20.8
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
@ -521,27 +526,27 @@ PrefabInstance:
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 139.72
value: 153.2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: -0
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: -0.29617012
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: -0
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
value: -0.9551352
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
@ -556,7 +561,7 @@ PrefabInstance:
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}
propertyPath: m_LocalEulerAnglesHint.y propertyPath: m_LocalEulerAnglesHint.y
value: -325.54498
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8, - target: {fileID: -4216859302048453862, guid: a9464dd51bb1eef41b97d9dba3c56cf8,
type: 3} type: 3}

+ 3
- 3
Assets/Scripts/HammerController.cs View File

@ -33,8 +33,8 @@ public class HammerController : MonoBehaviour
void FixedUpdate() void FixedUpdate()
{ {
float ratio = (Mathf.Sin(Time.time * Speed) + 1) / 2; float ratio = (Mathf.Sin(Time.time * Speed) + 1) / 2;
transform.forward = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.InverseTransformDirection(RotationAxis)) * startDir;
Vector3 hitDirection = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.InverseTransformDirection(RotationAxis)) * transform.parent.InverseTransformDirection(HitDirection) * -(Mathf.Cos(Time.time * Speed));
transform.forward = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.TransformDirection(RotationAxis)) * startDir;
Vector3 hitDirection = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.TransformDirection(RotationAxis)) * transform.parent.TransformDirection(HitDirection) * -(Mathf.Cos(Time.time * Speed));
Debug.DrawRay(transform.position, hitDirection * Force, Color.green); Debug.DrawRay(transform.position, hitDirection * Force, Color.green);
} }
@ -46,7 +46,7 @@ public class HammerController : MonoBehaviour
if (horse != null) if (horse != null)
{ {
float ratio = (Mathf.Sin(Time.time * Speed) + 1) / 2; float ratio = (Mathf.Sin(Time.time * Speed) + 1) / 2;
Vector3 hitDirection = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.InverseTransformDirection(RotationAxis)) * transform.parent.InverseTransformDirection(HitDirection) * -(Mathf.Cos(Time.time * Speed));
Vector3 hitDirection = Quaternion.AngleAxis(Mathf.Lerp(AngleLimit.x, AngleLimit.y, ratio), transform.parent.TransformDirection(RotationAxis)) * transform.parent.TransformDirection(HitDirection) * -(Mathf.Cos(Time.time * Speed));
horse.AddForce((hitDirection.normalized + Vector3.up) * Force); horse.AddForce((hitDirection.normalized + Vector3.up) * Force);
Debug.Log("Hitting horse"); Debug.Log("Hitting horse");

+ 93
- 11
Assets/Scripts/Input/BallController.cs View File

@ -5,33 +5,115 @@ using UnityEngine;
public class BallController : MonoBehaviour public class BallController : MonoBehaviour
{ {
public bool EatHorse;
public int HorseCount; public int HorseCount;
public float size;
public float size = 1;
public GameObject horsePrefab; public GameObject horsePrefab;
// Start is called before the first frame update
void Start()
public HerdController herd;
public float Speed = 10;
private List<PlayerController> disabledHorses = new List<PlayerController>();
private Rigidbody rigid;
private Camera cam;
private Vector2 recievdInput;
private SphereCollider collider;
private void Start()
{ {
SpawnHorses();
herd = FindObjectOfType<HerdController>();
rigid = GetComponent<Rigidbody>();
collider = GetComponent<SphereCollider>();
cam = Camera.main;
Debug.Log(herd.Centre.position);
} }
// Update is called once per frame // Update is called once per frame
void Update()
void FixedUpdate()
{ {
if (EatHorse)
{
rigid.isKinematic = false;
collider.enabled = true;
foreach (PlayerController horse in herd.Herd)
{
if (horse.GetComponent<PlayerController>().enabled)
{
horse.AddForce((transform.position - horse.transform.position).normalized * 20);
if (Vector3.Distance(horse.transform.position, transform.position) < size * 2)
AddHorse(horse);
}
}
}
else
{
rigid.isKinematic = true;
collider.enabled = false;
size = 1;
if (disabledHorses.Count != 0)
{
foreach (PlayerController horse in disabledHorses)
{
horse.enabled = true;
horse.cController.enabled = true;
horse.transform.parent = herd.transform;
horse.moveDirection = Vector3.zero;
var vec = horse.transform.eulerAngles;
vec.x = Mathf.Round(vec.x / 90) * 90;
vec.y = Mathf.Round(vec.y / 90) * 90;
vec.z = Mathf.Round(vec.z / 90) * 90;
horse.transform.eulerAngles = vec;
}
disabledHorses.Clear();
}
}
DoMove();
}
public void DoMove()
{
Vector3 direction = cam.transform.rotation * new Vector3(recievdInput.x, 0.0f, recievdInput.y);
rigid.AddForce(direction * Speed * Time.fixedDeltaTime,ForceMode.VelocityChange);
}
public void GetInput(Vector2 input)
{
recievdInput = input;
} }
public void SpawnHorses()
private void AddHorse(PlayerController horse)
{ {
for (int i = 0; i < HorseCount; i++)
size += 0.5f / (size*10);
collider.radius = size;
foreach(Transform child in transform)
{ {
Vector3 position = Random.onUnitSphere * size + transform.position;
Instantiate(horsePrefab, position,Random.rotation , transform);
child.localPosition = child.localPosition.normalized * size;
} }
horse.GetComponent<PlayerController>().enabled = false;
horse.GetComponent<CharacterController>().enabled = false;
Vector3 position = Random.onUnitSphere * size + transform.position;
horse.transform.position = position;
horse.transform.rotation = Random.rotation;
horse.transform.parent = transform;
disabledHorses.Add(horse);
} }
} }

+ 48
- 4
Assets/Scripts/Input/HerdController.cs View File

@ -21,13 +21,15 @@ public class HerdController : MonoBehaviour
private float WaitTime; private float WaitTime;
[SerializeField] [SerializeField]
private Transform Centre;
public Transform Centre;
private float lastTime; private float lastTime;
private List<PlayerController> Herd;
public List<PlayerController> Herd;
private Vector2 recievedInput; private Vector2 recievedInput;
public GameStateController GameState; public GameStateController GameState;
public BallController Ball;
void Start() void Start()
{ {
@ -44,8 +46,50 @@ public class HerdController : MonoBehaviour
Herd.ForEach(p => p.SetMovement(input)); Herd.ForEach(p => p.SetMovement(input));
recievedInput = input; recievedInput = input;
Ball.GetInput(input);
} }
private void OnSprint(InputValue value)
{
int input = (int)value.Get<float>();
Debug.Log("Sprint: " + input);
if (input == 1)
{
Ball.EatHorse = true;
Ball.transform.position = Centre.position;
}
else
{
Ball.EatHorse = false;
}
}
private Vector3 GetCentre()
{
Vector3 centreofMass = Vector3.zero;
int CountedHorses = 0;
foreach (PlayerController horse in Herd)
{
if (horse.isGrounded || Time.time < 5)
{
centreofMass += horse.transform.position;
CountedHorses++;
}
}
if (CountedHorses != 0)
{
return centreofMass / CountedHorses;
}
else
{
return Vector3.one;
}
}
[ContextMenu("Spawn")] [ContextMenu("Spawn")]
private void SpawnHerd() private void SpawnHerd()
@ -126,7 +170,7 @@ public class HerdController : MonoBehaviour
bound.Encapsulate(horse.transform.position); bound.Encapsulate(horse.transform.position);
centreofMass += horse.transform.position; centreofMass += horse.transform.position;
CountedHorses++; CountedHorses++;
} }
} }
if (CountedHorses != 0) if (CountedHorses != 0)
@ -137,7 +181,7 @@ public class HerdController : MonoBehaviour
} }
else else
{ {
GameState.LoseState();
GameState.LoseState();
} }
} }

+ 6
- 3
Assets/Scripts/Input/PlayerController.cs View File

@ -65,7 +65,7 @@ public class PlayerController : MonoBehaviour
if (!isRagdoll) if (!isRagdoll)
{ {
moveDirection = Vector3.zero; moveDirection = Vector3.zero;
moveDirection += new Vector3(HorseX, 0, HorseZ) * (walkSpeed * (1 + speedMulitplier));
moveDirection += cam.transform.rotation * new Vector3(HorseX, 0, HorseZ) * (walkSpeed * (1 + speedMulitplier));
} }
} }
@ -114,12 +114,15 @@ public class PlayerController : MonoBehaviour
public IEnumerator RandomWait(float wait) public IEnumerator RandomWait(float wait)
{ {
Vector3 input = receivedInput;
Vector3 input = new Vector3(receivedInput.x, 0.0f, receivedInput.y);
yield return new WaitForSeconds(UnityEngine.Random.Range(0, wait / 2)); yield return new WaitForSeconds(UnityEngine.Random.Range(0, wait / 2));
if (cController.isGrounded) if (cController.isGrounded)
{ {
Vector3 rotateDir = new Vector3(90 * Math.Sign(input.y), 0, -90 * Math.Sign(input.x));
Vector3 rotateDir = new Vector3(90 * Math.Sign(input.z),0.0f, -90 * Math.Sign(input.x));
//model.transform.rotation *= Quaternion.AngleAxis(cam.transform.eulerAngles.y, Vector3.up) * Quaternion.Euler(rotateDir);
model.transform.Rotate(rotateDir, Space.World); model.transform.Rotate(rotateDir, Space.World);
} }
} }

+ 83
- 0
Assets/WorldAssets/Prefabs/HorseBall.prefab View File

@ -0,0 +1,83 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8253619032045175705
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8253619032045175711}
- component: {fileID: 8253619032045175704}
- component: {fileID: 5790973319256092316}
- component: {fileID: 6514331592746740632}
m_Layer: 0
m_Name: HorseBall
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8253619032045175711
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8253619032045175705}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 100, z: 100}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8253619032045175704
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8253619032045175705}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fbe2851429fe8e8468394372c097ba45, type: 3}
m_Name:
m_EditorClassIdentifier:
EatHorse: 0
HorseCount: 0
size: 1
horsePrefab: {fileID: -927199367670048503, guid: 707f698da07e87f4ab470faa7ed70d74,
type: 3}
herd: {fileID: 0}
Speed: 100
--- !u!54 &5790973319256092316
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8253619032045175705}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!135 &6514331592746740632
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8253619032045175705}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}

+ 7
- 0
Assets/WorldAssets/Prefabs/HorseBall.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d019eaad4f87842448d362a485c2990b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save