playMaker

Author Topic: Loop count exceeded maximum...[SOLVED]  (Read 3272 times)

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Loop count exceeded maximum...[SOLVED]
« 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;

    }
}


« Last Edit: September 10, 2018, 01:54:08 AM by jeanfabre »

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Loop count exceeded maximum...
« Reply #1 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 :

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Loop count exceeded maximum...
« Reply #2 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.
« Last Edit: September 09, 2018, 07:03:04 AM by Franck »

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Loop count exceeded maximum...
« Reply #3 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 :)

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Loop count exceeded maximum...
« Reply #4 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;
    }
}

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Loop count exceeded maximum...
« Reply #5 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)

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Loop count exceeded maximum...
« Reply #6 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Loop count exceeded maximum...
« Reply #7 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
« Last Edit: September 10, 2018, 08:38:33 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Loop count exceeded maximum...[SOLVED]
« Reply #8 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
 ;)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Loop count exceeded maximum...[SOLVED]
« Reply #9 on: September 10, 2018, 12:55:21 PM »
yep...

Thanks :)

Bye,

 Jean