Fixed major AI issues
Tweaked AI parameters Improved AI behaviour to avoid getting stuck near walls Changed boost conditions
This commit is contained in:
@@ -166,7 +166,7 @@ SphereCollider:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 10774711}
|
m_GameObject: {fileID: 10774711}
|
||||||
m_Material: {fileID: 13400000, guid: 5e7ec1c29ced4ed4e88e03a2da959d27, type: 2}
|
m_Material: {fileID: 0}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -226,7 +226,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 10774711}
|
m_GameObject: {fileID: 10774711}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 2, z: 0}
|
m_LocalPosition: {x: 0, y: 1.01, z: 0}
|
||||||
m_LocalScale: {x: 2, y: 2, z: 2}
|
m_LocalScale: {x: 2, y: 2, z: 2}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
@@ -722,7 +722,7 @@ BoxCollider:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 268360628}
|
m_GameObject: {fileID: 268360628}
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 13400000, guid: 5e7ec1c29ced4ed4e88e03a2da959d27, type: 2}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -813,6 +813,7 @@ MonoBehaviour:
|
|||||||
inputVector: {x: 0, y: 0, z: 0}
|
inputVector: {x: 0, y: 0, z: 0}
|
||||||
turnRadius: 6
|
turnRadius: 6
|
||||||
destinationOffset: 6.5
|
destinationOffset: 6.5
|
||||||
|
maxBoostDist: 4
|
||||||
distanceToTarget: 0
|
distanceToTarget: 0
|
||||||
angleToDestination: 0
|
angleToDestination: 0
|
||||||
angleToBall: 0
|
angleToBall: 0
|
||||||
@@ -1264,6 +1265,7 @@ MonoBehaviour:
|
|||||||
inputVector: {x: 0, y: 0, z: 0}
|
inputVector: {x: 0, y: 0, z: 0}
|
||||||
turnRadius: 6
|
turnRadius: 6
|
||||||
destinationOffset: 6.5
|
destinationOffset: 6.5
|
||||||
|
maxBoostDist: 4
|
||||||
distanceToTarget: 0
|
distanceToTarget: 0
|
||||||
angleToDestination: 0
|
angleToDestination: 0
|
||||||
angleToBall: 0
|
angleToBall: 0
|
||||||
@@ -1308,7 +1310,7 @@ BoxCollider:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 384291585}
|
m_GameObject: {fileID: 384291585}
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 13400000, guid: 5e7ec1c29ced4ed4e88e03a2da959d27, type: 2}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1500,7 +1502,7 @@ BoxCollider:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 562159198}
|
m_GameObject: {fileID: 562159198}
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 13400000, guid: 5e7ec1c29ced4ed4e88e03a2da959d27, type: 2}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -2364,12 +2366,17 @@ PrefabInstance:
|
|||||||
- target: {fileID: 1046011661964092265, guid: dc95d43174591064fa2b839a78374e0d,
|
- target: {fileID: 1046011661964092265, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: turnRadius
|
propertyPath: turnRadius
|
||||||
value: 8
|
value: 6
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1046011661964092265, guid: dc95d43174591064fa2b839a78374e0d,
|
- target: {fileID: 1046011661964092265, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: destinationOffset
|
propertyPath: destinationOffset
|
||||||
value: 8
|
value: 5
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1046011661964092265, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: maxBoostDist
|
||||||
|
value: 6
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
type: 3}
|
type: 3}
|
||||||
@@ -2379,7 +2386,7 @@ PrefabInstance:
|
|||||||
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: aiControlled
|
propertyPath: aiControlled
|
||||||
value: 0
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
- target: {fileID: 1046011661964092268, guid: dc95d43174591064fa2b839a78374e0d,
|
||||||
type: 3}
|
type: 3}
|
||||||
@@ -2531,7 +2538,7 @@ MeshCollider:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1228261470}
|
m_GameObject: {fileID: 1228261470}
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 13400000, guid: 5e7ec1c29ced4ed4e88e03a2da959d27, type: 2}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
|
|||||||
@@ -280,6 +280,102 @@ BoxCollider:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1.7904701, y: 0.70985544, z: 0.13607855}
|
m_Size: {x: 1.7904701, y: 0.70985544, z: 0.13607855}
|
||||||
m_Center: {x: -0.9024396, y: 0.3283303, z: -0.000000078280046}
|
m_Center: {x: -0.9024396, y: 0.3283303, z: -0.000000078280046}
|
||||||
|
--- !u!82 &423715266
|
||||||
|
AudioSource:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 423715263}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
|
m_audioClip: {fileID: 0}
|
||||||
|
m_PlayOnAwake: 1
|
||||||
|
m_Volume: 1
|
||||||
|
m_Pitch: 1
|
||||||
|
Loop: 0
|
||||||
|
Mute: 0
|
||||||
|
Spatialize: 0
|
||||||
|
SpatializePostEffects: 0
|
||||||
|
Priority: 128
|
||||||
|
DopplerLevel: 1
|
||||||
|
MinDistance: 1
|
||||||
|
MaxDistance: 500
|
||||||
|
Pan2D: 0
|
||||||
|
rolloffMode: 0
|
||||||
|
BypassEffects: 0
|
||||||
|
BypassListenerEffects: 0
|
||||||
|
BypassReverbZones: 0
|
||||||
|
rolloffCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
panLevelCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
spreadCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
reverbZoneMixCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
--- !u!114 &423715269
|
--- !u!114 &423715269
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -295,6 +391,7 @@ MonoBehaviour:
|
|||||||
hoverIntensity: 3
|
hoverIntensity: 3
|
||||||
defaultIntensity: 1
|
defaultIntensity: 1
|
||||||
lerpSpeed: 8
|
lerpSpeed: 8
|
||||||
|
hoverSound: {fileID: 8300000, guid: e75abec2b09871a429a53346b4579798, type: 3}
|
||||||
target: {fileID: 2130034758}
|
target: {fileID: 2130034758}
|
||||||
--- !u!1 &1392065296
|
--- !u!1 &1392065296
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -677,6 +774,102 @@ GameObject:
|
|||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 1969327177}
|
m_PrefabInstance: {fileID: 1969327177}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!82 &2121460458
|
||||||
|
AudioSource:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2121460457}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
|
m_audioClip: {fileID: 0}
|
||||||
|
m_PlayOnAwake: 1
|
||||||
|
m_Volume: 1
|
||||||
|
m_Pitch: 0.75
|
||||||
|
Loop: 0
|
||||||
|
Mute: 0
|
||||||
|
Spatialize: 0
|
||||||
|
SpatializePostEffects: 0
|
||||||
|
Priority: 128
|
||||||
|
DopplerLevel: 1
|
||||||
|
MinDistance: 1
|
||||||
|
MaxDistance: 500
|
||||||
|
Pan2D: 0
|
||||||
|
rolloffMode: 0
|
||||||
|
BypassEffects: 0
|
||||||
|
BypassListenerEffects: 0
|
||||||
|
BypassReverbZones: 0
|
||||||
|
rolloffCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
panLevelCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
spreadCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
reverbZoneMixCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
--- !u!114 &2121460459
|
--- !u!114 &2121460459
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -692,6 +885,7 @@ MonoBehaviour:
|
|||||||
hoverIntensity: 3
|
hoverIntensity: 3
|
||||||
defaultIntensity: 1
|
defaultIntensity: 1
|
||||||
lerpSpeed: 8
|
lerpSpeed: 8
|
||||||
|
hoverSound: {fileID: 8300000, guid: e75abec2b09871a429a53346b4579798, type: 3}
|
||||||
target: {fileID: 1453726629}
|
target: {fileID: 1453726629}
|
||||||
--- !u!65 &2121460460
|
--- !u!65 &2121460460
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
|
|||||||
@@ -9,14 +9,16 @@ public class AIController : MonoBehaviour
|
|||||||
public Vector3 inputVector;
|
public Vector3 inputVector;
|
||||||
public float turnRadius = 1;
|
public float turnRadius = 1;
|
||||||
public float destinationOffset;
|
public float destinationOffset;
|
||||||
|
public float maxBoostDist = 3;
|
||||||
|
|
||||||
public float distanceToTarget;
|
public float distanceToTarget; //Distance to the point, placed behind the ball
|
||||||
public float angleToDestination;
|
public float angleToDestination;
|
||||||
public float angleToBall;
|
public float angleToBall;
|
||||||
public float distanceToBall;
|
public float distanceToBall;
|
||||||
|
|
||||||
private Vector3 destination;
|
private Vector3 destination;
|
||||||
private Vector3 directionVector;
|
private Vector3 directionVector;
|
||||||
|
private float rotationTimeout = 0;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -53,8 +55,9 @@ public class AIController : MonoBehaviour
|
|||||||
Debug.DrawLine(this.transform.position, this.destination, Color.yellow, 0f, false);
|
Debug.DrawLine(this.transform.position, this.destination, Color.yellow, 0f, false);
|
||||||
Debug.DrawLine(this.targetGoal.position, this.destination, Color.yellow, 0f, false);
|
Debug.DrawLine(this.targetGoal.position, this.destination, Color.yellow, 0f, false);
|
||||||
Gizmos.DrawSphere(this.destination, 1);
|
Gizmos.DrawSphere(this.destination, 1);
|
||||||
|
Debug.DrawRay(transform.position, this.transform.forward * 3.8f, Color.white, .5f);
|
||||||
Debug.DrawRay(transform.position, this.transform.forward * 10, Color.green);
|
Debug.DrawRay(transform.position, this.transform.forward * 10, Color.green);
|
||||||
Debug.DrawRay(transform.position, this.directionVector.normalized * 10, Color.red);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,38 +69,42 @@ public class AIController : MonoBehaviour
|
|||||||
inputs[AiInputs.VERTICAL] = 0;
|
inputs[AiInputs.VERTICAL] = 0;
|
||||||
inputs[AiInputs.BOOST] = 0;
|
inputs[AiInputs.BOOST] = 0;
|
||||||
|
|
||||||
|
//Move forward if we are too far away
|
||||||
if (this.distanceToTarget > 4)
|
if (this.distanceToTarget > 4)
|
||||||
{
|
{
|
||||||
inputs[AiInputs.VERTICAL] = 1;
|
inputs[AiInputs.VERTICAL] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.DrawRay(transform.position, transform.TransformDirection(-Vector3.forward) * 8, Color.magenta, 0, false);
|
|
||||||
|
|
||||||
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(this.angleToDestination * 10) / 10;
|
|
||||||
if (this.distanceToTarget < this.turnRadius)
|
|
||||||
{
|
|
||||||
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(-this.angleToBall * 10) / 10;
|
|
||||||
if (Physics.Raycast(transform.position, transform.TransformDirection(-Vector3.forward), 8))
|
|
||||||
{
|
|
||||||
inputs[AiInputs.BOOST] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (this.distanceToBall < this.turnRadius)
|
|
||||||
{
|
|
||||||
RaycastHit hit;
|
RaycastHit hit;
|
||||||
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(-this.angleToBall * 10) / 10;
|
//If we hit something head on, stop, drop and rotate (emergency rotate)
|
||||||
if (Physics.Raycast(transform.position, this.directionVector, out hit, 5))
|
if (Physics.Raycast(transform.position, this.transform.forward, out hit, 3.8f))
|
||||||
{
|
{
|
||||||
if(hit.transform.tag == "Ball")
|
this.rotationTimeout = .2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rotate if we are close enough to the target (behind the ball) but not if emergency rotation is active
|
||||||
|
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(this.angleToDestination * 10) / 10;
|
||||||
|
if (this.distanceToTarget < this.turnRadius && this.rotationTimeout < 0)
|
||||||
|
{
|
||||||
|
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(-this.angleToBall * 10) / 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rotationTimeout -= Time.deltaTime;
|
||||||
|
if(rotationTimeout > 0)
|
||||||
|
{
|
||||||
|
inputs[AiInputs.HORIZONTAL] = .5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Shoot a ray backwards and boost if we are close enough to the target (behind the ball) to avoid shooting towards our own goal
|
||||||
|
if (Physics.Raycast(transform.position, -this.transform.forward, out hit, 15))
|
||||||
|
{
|
||||||
|
if (hit.transform.tag == "Ball" && this.distanceToTarget < this.maxBoostDist)
|
||||||
{
|
{
|
||||||
inputs[AiInputs.BOOST] = 1;
|
inputs[AiInputs.BOOST] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.inputVector = new Vector3(inputs[AiInputs.HORIZONTAL], inputs[AiInputs.VERTICAL], inputs[AiInputs.BOOST]);
|
this.inputVector = new Vector3(inputs[AiInputs.HORIZONTAL], inputs[AiInputs.VERTICAL], inputs[AiInputs.BOOST]);
|
||||||
//Left/Right, Fwd/Bkwd, Boost
|
//Left/Right, Fwd/Bkwd, Boost
|
||||||
|
|||||||
@@ -5,16 +5,18 @@ using UnityEngine;
|
|||||||
public class GlowOnHover : MonoBehaviour
|
public class GlowOnHover : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float hoverIntensity, defaultIntensity, lerpSpeed = 1;
|
public float hoverIntensity, defaultIntensity, lerpSpeed = 1;
|
||||||
|
public AudioClip hoverSound;
|
||||||
public Renderer target;
|
public Renderer target;
|
||||||
private float fromIntensity, toIntensity, currentIntensity, t;
|
private float fromIntensity, toIntensity, currentIntensity, t;
|
||||||
private Material material;
|
private Material material;
|
||||||
private Color defaultColor;
|
private Color defaultColor;
|
||||||
|
private AudioSource audioSource;
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
this.material = this.target.material;
|
this.material = this.target.material;
|
||||||
this.defaultColor = material.GetColor("_EmissionColor");
|
this.defaultColor = material.GetColor("_EmissionColor");
|
||||||
this.toIntensity = defaultIntensity;
|
this.toIntensity = defaultIntensity;
|
||||||
|
this.audioSource = GetComponent<AudioSource>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -40,6 +42,10 @@ public class GlowOnHover : MonoBehaviour
|
|||||||
private void OnMouseEnter()
|
private void OnMouseEnter()
|
||||||
{
|
{
|
||||||
this.lerpEmission(this.currentIntensity, this.hoverIntensity);
|
this.lerpEmission(this.currentIntensity, this.hoverIntensity);
|
||||||
|
if (this.hoverSound && this.audioSource)
|
||||||
|
{
|
||||||
|
this.audioSource.PlayOneShot(this.hoverSound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseExit()
|
private void OnMouseExit()
|
||||||
|
|||||||
Reference in New Issue
Block a user