Lawnmower Chase Work
Gardener chases but gets flipped
This commit is contained in:
@@ -443520,15 +443520,15 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalScale.x
|
propertyPath: m_LocalScale.x
|
||||||
value: 3.68
|
value: 1.5
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalScale.y
|
propertyPath: m_LocalScale.y
|
||||||
value: 2
|
value: 1.5
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalScale.z
|
propertyPath: m_LocalScale.z
|
||||||
value: 2
|
value: 1.5
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
@@ -443540,19 +443540,23 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: 0.83432513
|
value: 0.97629607
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.01966123
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.5507691
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.012979111
|
value: -0.21643952
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 6004009293778554413, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
@@ -443572,7 +443576,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7134386036058471687, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 7134386036058471687, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: followers.Array.data[0].faceDirection
|
propertyPath: followers.Array.data[0].faceDirection
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7402687028936857164, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
- target: {fileID: 7402687028936857164, guid: 1fda7fccaa5fbd04695f4c98d29bcbe0, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ public class GardenerChaseBehavior : MonoBehaviour
|
|||||||
tweenRef.Stop();
|
tweenRef.Stop();
|
||||||
Destroy(ChaseSpline);
|
Destroy(ChaseSpline);
|
||||||
var gardenerSpriteRef = gameObject.transform.Find("GardenerRunningSprite");
|
var gardenerSpriteRef = gameObject.transform.Find("GardenerRunningSprite");
|
||||||
//ReparentWithExactWorldTransform(gardenerSpriteRef, lawnMowerRef.transform);
|
|
||||||
gardenerSpriteRef.transform.SetParent(lawnMowerRef.transform, true);
|
gardenerSpriteRef.transform.SetParent(lawnMowerRef.transform, true);
|
||||||
//Vector3 pos = gardenerSpriteRef.position;
|
|
||||||
//pos.y = lawnMowerRef.transform.position.y;
|
|
||||||
//gardenerSpriteRef.position = pos;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void HandleTweenStarted ()
|
void HandleTweenStarted ()
|
||||||
@@ -47,34 +44,7 @@ public class GardenerChaseBehavior : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public void ReparentWithExactWorldTransform(Transform objectToMove, Transform newParent)
|
|
||||||
{
|
|
||||||
// Store the original world position, rotation, and scale
|
|
||||||
Vector3 originalWorldPosition = objectToMove.position;
|
|
||||||
Quaternion originalWorldRotation = objectToMove.rotation;
|
|
||||||
Vector3 originalWorldScale = objectToMove.lossyScale;
|
|
||||||
|
|
||||||
// First change the parent
|
|
||||||
objectToMove.SetParent(newParent, false); // Set worldPositionStays to false
|
|
||||||
|
|
||||||
// Then manually restore world position and rotation
|
|
||||||
objectToMove.position = originalWorldPosition;
|
|
||||||
objectToMove.rotation = originalWorldRotation;
|
|
||||||
|
|
||||||
// Correct the scale (this is tricky because localScale isn't the same as world scale)
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
Vector3 newLocalScale = objectToMove.localScale;
|
|
||||||
Vector3 parentWorldScale = newParent.lossyScale;
|
|
||||||
|
|
||||||
// Adjust local scale to maintain world scale
|
|
||||||
newLocalScale.x = (Mathf.Approximately(parentWorldScale.x, 0f)) ? 0f : originalWorldScale.x / parentWorldScale.x;
|
|
||||||
newLocalScale.y = (Mathf.Approximately(parentWorldScale.y, 0f)) ? 0f : originalWorldScale.y / parentWorldScale.y;
|
|
||||||
newLocalScale.z = (Mathf.Approximately(parentWorldScale.z, 0f)) ? 0f : originalWorldScale.z / parentWorldScale.z;
|
|
||||||
|
|
||||||
objectToMove.localScale = newLocalScale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user