Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Franck on September 09, 2018, 06:31:06 AM

Title: Loop count exceeded maximum...[SOLVED]
Post 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:

Code: [Select]
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)
Title: Re: Loop count exceeded maximum...
Post by: heavygunner on September 09, 2018, 06:49:56 AM
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 :
Title: Re: Loop count exceeded maximum...
Post by: Franck on September 09, 2018, 06:55:54 AM
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.
Title: Re: Loop count exceeded maximum...
Post by: Franck on September 09, 2018, 08:25:25 AM
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 :)
Title: Re: Loop count exceeded maximum...
Post by: Franck on September 09, 2018, 10:16:15 AM
I answer to myself:

Code: [Select]
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;
    }
}
Title: Re: Loop count exceeded maximum...
Post by: heavygunner on September 09, 2018, 06:18:21 PM
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)
Title: Re: Loop count exceeded maximum...
Post by: Franck on September 10, 2018, 01:50:04 AM
Yeah clearly right lol !
I prefer not to delete it, maybe it will help other people who learn like me lol
Title: Re: Loop count exceeded maximum...
Post by: jeanfabre on September 10, 2018, 01:53:58 AM
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
Title: Re: Loop count exceeded maximum...[SOLVED]
Post by: djaydino on September 10, 2018, 08:39:43 AM
Hi.
Just edited jeans post as i think he mend :  are you are not the only one
 ;)
Title: Re: Loop count exceeded maximum...[SOLVED]
Post by: jeanfabre on September 10, 2018, 12:55:21 PM
yep...

Thanks :)

Bye,

 Jean