Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Franck on September 09, 2018, 06:31:06 AM
-
Hi there,
I try to make that when my character runs it throws a gun animation that comes against the body.
Unfortunately, I have an error in the console and the game mode stops because of a loop count.
Here are some screens of my FSM. I guess the loop is when I get to the float compare because of the checkbox "every frame". When I uncheck it I have no more error but the animation does not start. What's strange is that it does not do that to me all the time. Sometimes I get the animation, but the next time the mistake happens ...
And for info, I have a speed script to get the speed of my character:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Speed : MonoBehaviour {
public float speed = 0;
Vector3 lastPosition = Vector3.zero;
// Update is called once per frame
void FixedUpdate () {
speed = (((transform.position - lastPosition).magnitude) / Time.deltaTime);
lastPosition = transform.position;
}
}
(https://imageshack.com/a/img923/7370/rLEXYr.jpg)
-
In my case, Movement and Jump FSm should be disabled when player collided with enemy. FSM worked, but I also got same error as you. That can be fixed by adding new state with NEXT FRAME EVENT action.
More :
-
Hi heavygunner, Thanx for your reply.
in my case I must to go to isRunning and go Back to isNotRunning when running key is up.
Where should I put the NEXT FRAME EVENT action?
EDIT: Found it. I put a transition state between Idle and Running.
-
Any idea for my speed script to just get the forward speed and not the jump speed?
Because when I jump I have the running animation. And when the game begin my character fall on floor and get a speed that begin the animation too. It's a little bit annoying :)
-
I answer to myself:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Speed : MonoBehaviour {
public float horizontalSpeed = 0;
public float verticalSpeed = 0;
public float overallSpeed = 0;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
Vector3 horizontalVelocity = controller.velocity;
horizontalVelocity = new Vector3(controller.velocity.x, 0, controller.velocity.z);
horizontalSpeed = horizontalVelocity.magnitude;
verticalSpeed = controller.velocity.y;
overallSpeed = controller.velocity.magnitude;
}
}
-
I answer to myself:
Yah ! That is common when we are in learning mode.
I also posted some threads and deleted later after found solution.
Good luck ! 8)
-
Yeah clearly right lol !
I prefer not to delete it, maybe it will help other people who learn like me lol
-
Hi,
yes, please, never delete a post because you found the solution, chances are you are not the only one who had this problem, and so it helps others.
Bye,
Jean
-
Hi.
Just edited jeans post as i think he mend : are you are not the only one
;)
-
yep...
Thanks :)
Bye,
Jean