Skip to content
Snippets Groups Projects
Commit 2faa1c57 authored by John Schihada's avatar John Schihada
Browse files

Fixed some TaskCharacter- and typing-bugs

parent 399d0f56
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,10 @@ public void NextSentence() {
textReseted = false;
}
else {
letterIndex = 0;
typingActive = false;
timer = 0;
textReseted = false;
textDisplay.text = "";
}
}
......
......@@ -12,6 +12,8 @@ public class TaskCharakterAnimation : MonoBehaviour
private Transform currentTransform;
private float currentDistance;
//When changing walking/standing/happy booleans -> the state-variables in the animationController must also be changed
//For change of the task-character movements, maybe the transitions in the animationController have also to be adjusted
private float walkingTime = 5;
private bool walking = true;
private float standingTime = 3;
......@@ -51,9 +53,10 @@ void Update()
this.walking = false;
this.standing = true;
this.timer = 0;
rotate = false;
//Change boolean for switching to Standing-State in AnimationController
anim.SetBool("standing", true);
//Enable enter-key for talking
//Enable enter-key for talking for Charakter-Dialog
setPlayerInTalkingZone(true);
//Face walkAroundObject to Player (but only on y-Axis, so ignore x-and z-axis)
......@@ -64,24 +67,6 @@ void Update()
else {
//disable enter-key for talking
setPlayerInTalkingZone(false);
//Change to walking State after Talking Zone so that player can stay inside the radiusAroundObject
rotate = false;
this.timer = 0;
//Change boolean for switching to Walking-State in AnimationController
anim.SetBool("standing", false);
}
//Calculate distance from tree, so that the TaskCharacter only walks in a specific radius around the tree
//so that the player always knows where he is
currentDistance = (currentTransform.position - walkAroundObject.transform.position).magnitude;
//Turn on the radius-edges around the radiusAroundObject
if (currentDistance > radiusAroundObject)
{
//Change roation if TaskCharacter is at the edges of the radius
currentTransform.RotateAround(currentTransform.position, Vector3.up, 30 * Time.deltaTime);
//return, because at the radius-edges we only want to rotate without standing/walking
return;
}
this.timer += Time.deltaTime;
......@@ -124,11 +109,35 @@ void Update()
this.standing = false;
this.walking = true;
this.timer = 0;
//Rotate Character randomly
nextRotation = Random.Range(0, 180);
int positive = (int)Random.Range(0, 2);
if (positive == 0)
nextRotation *= -1;
//Calculate distance from tree, so that the TaskCharacter only walks in a specific radius around the tree
//so that the player always knows where he is
currentDistance = (currentTransform.position - walkAroundObject.transform.position).magnitude;
//Turn on the radius-edges around the radiusAroundObject
if (currentDistance > radiusAroundObject)
{
//Rotate Towards tree if radiusAroundObject is out of radius
//Rotate randomly between +/-5° towards the radiusAroundObject
int temp = Random.Range(0, 5);
int positive = (int)Random.Range(0, 2);
//Calculate NextRotation towards radiusAroundObject
nextRotation = Vector3.Angle(currentTransform.forward, (walkAroundObject.transform.position-currentTransform.position).normalized);
if (positive == 0)
nextRotation -= temp;
else
nextRotation += temp;
}
else
{
//Rotate Character randomly if radiusAroundObject is inside the radius
//Rotate inside the range of -180° and 180° because a normal human would turn e.g. -60° instead of 240°
nextRotation = Random.Range(0, 180);
int positive = (int)Random.Range(0, 2);
if (positive == 0)
nextRotation *= -1;
}
rotationUnits = nextRotation / (rotationTime/Time.deltaTime);
rotate = true;
}
......@@ -153,12 +162,13 @@ public void stopHappy(Fact startFact) {
public void resetToStart() {
//On Reset: Player must go into walking state, because it could be that after the happy/running-animation the player is
//out of radius and rotates -> AnimationController StateMachine always changes into walking-state after hyppAnimation
walking = true;
standing = false;
rotate = true;
walking = false;
standing = true;
rotate = false;
nextRotation = 0;
rotationUnits = 0;
playerInTalkingZone = false;
timer = 0;
}
//Static Method for CharacterDialog
......
......@@ -47,7 +47,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
walkAroundObject: {fileID: 0}
--- !u!1101 &1101065367606003302
--- !u!1101 &1101341565081408182
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
......@@ -59,16 +59,16 @@ AnimatorStateTransition:
m_ConditionEvent: solved
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102240409349395686}
m_DstState: {fileID: 1102119675311824806}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 3
m_ExitTime: 0.5639534
m_HasExitTime: 0
m_HasFixedDuration: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
......@@ -239,7 +239,7 @@ AnimatorState:
m_Speed: 2
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101065367606003302}
- {fileID: 1101341565081408182}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment