HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Prevent Turning When IDLE  (Read 2808 times)

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Prevent Turning When IDLE
« on: Feb 22, 16, 12:46:29 PM »

Some designers may not wish Characters to rotate when at Idle.
By default, when you rotate the camera more than 25 degrees or so, the Turning animations are called, and
the character will rotate/turn to match the cameras rotation.

The following code will either call for turning, or not, depending on how you customize it.

This simply describes how you may prevent characters from turning while idle, allowing you to rotate the camera
and view your character from any angle.

CLIENT SIDE: E_ACCControllerClassMethods:method _HE_ACCC_NavigateLocal

Scroll down and find the following code:

The two BOLD commented lines will CAUSE the character to turn when IDLE.
To prevent turning when IDLE (unless you have custom code elsewhere that causes it)
Comment the two BOLD lines in your own script, AS YOU SEE BELOW.

Quote
// do a running average of camera heading, to fuzzily detect when camera has stopped turning (mice are imprecise!)
        if (me.HeroEngineACCC_State = IDLE)
          me.HeroEngineACCC_LastCameraHeading = (me.HeroEngineACCC_LastCameraHeading + (camrot.y*5))/6
          diff as Float = fabs(me.HeroEngineACCC_LastCameraHeading - camrot.y )
          if (diff < .01)
            //me.HeroEngineACCC_DesiredRotation.y = -camrot.y
            //me.E_ACCCRotationDone = false

          .
         
        else
          me.HeroEngineACCC_LastCameraHeading = camrot.y
          me.HeroEngineACCC_DesiredRotation.y = -camrot.y
          me.E_ACCCRotationDone = false
        .



The following describes how to prevent turning ONLY when NOT IN PLAY mode(char will still rotate at IDLE
 when in PLAY mode)
To Ensure that turning does not occur when in FLY mode or Any mode other than PLAY mode
use the following instead:

Quote
// do a running average of camera heading, to fuzzily detect when camera has stopped turning (mice are imprecise!)
        if (me.HeroEngineACCC_State = IDLE)
          me.HeroEngineACCC_LastCameraHeading = (me.HeroEngineACCC_LastCameraHeading + (camrot.y*5))/6
          diff as Float = fabs(me.HeroEngineACCC_LastCameraHeading - camrot.y )
          if (diff < .01)
            if $PLAYMODE._getPlayModeState() != ON
              //fancy custom stuff here, but char will not rotate at IDLE
              //unless called to do so.
            else
              me.HeroEngineACCC_DesiredRotation.y = -camrot.y
              me.E_ACCCRotationDone = false
            .

          .

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Prevent Turning When IDLE
« Reply #1 on: Feb 22, 16, 01:11:59 PM »

Nice and useful.

In the same area, could you also find what causes the character to move forward after side stepping (strafing)?

I step sideways using "a" and the character steps forward after that, then use "d" and it does it again. I have noticed that if one uses "a" and "d" rapidly, the character does not step forward.
« Last Edit: Feb 22, 16, 01:14:03 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Prevent Turning When IDLE
« Reply #2 on: Feb 22, 16, 01:40:51 PM »

Hrm, yeah i'll look for that, im working in that code atm anyway.

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Prevent Turning When IDLE
« Reply #3 on: Feb 22, 16, 02:10:20 PM »

The behavior you mention seems to come from the following block of code:

E_ACCControllerClassMethods:method _HE_ACCC_ResolveNavigation

Look near the bottom of the method and find:

Quote
      // END CHECK
      if me.E_ACCCAlwaysSlideTurn
        me._HE_ACCC_DoSlideTurn(elapsed)
      else
        me._HE_ACCC_DoAnimTurn(mychar,elapsed)
      .

I do not use the default chars or their .aas any longer, but i was able to force my char to do what you describe by
setting alwaysSlide to true like this:


CODE ATTACHED TO A BUTTON FOR TESTING:

Quote
      charNode as NodeRef of Class HBNode = SYSTEM.INFO.PLAYERCHARACTER
      cont as NodeRef of Class E_ACCController = char._accControllerRef
      elapsed as TimeInterval
        elapsed = 00:00:01
      if cont.E_ACCCAlwaysSlideTurn
        println("Always")
        cont._HE_ACCC_DoSlideTurn(elapsed)
      else
        cont.E_ACCCAlwaysSlideTurn = true
        println("Not always")
        cont._HE_ACCC_DoAnimTurn(charNode,elapsed)
      .

by clicking the button it set my chars slideTurn to true, so when I straffed, it did as you describe by blending the side
step with a turn forward.

I believe that the default chars have this set to "True" by default.  check that and see.

In short if you set your chars "E_ACCCAlwaysSlideTurn" value to false, it should eliminate the forward turn at the end
of the straff motion.

This field is on the _acccontrollerRef of your playerCharacter

if that works, then i guess we should put this under another topic.  Let me know.
« Last Edit: Feb 22, 16, 02:13:22 PM by ToY-Krun »
Logged

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Prevent Turning When IDLE
« Reply #4 on: Feb 22, 16, 02:45:54 PM »

bah... how many times can i misspell Strafe.....

there may be other settings that cause this, but thats all ive found so far.

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Prevent Turning When IDLE
« Reply #5 on: Feb 22, 16, 06:37:22 PM »

Thanks. Does this turn to look forward after the strafe also cause the character to step forward? Combined in 1 effect, or could they be separated?  We are looking to face forward after the strafe, but not walk forward.

Just hitting "a" and "d" will make the character walk forward quite a bit.

Then again this will most likely all change once we get the game character in.
« Last Edit: Feb 22, 16, 06:39:33 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Prevent Turning When IDLE
« Reply #6 on: Feb 22, 16, 06:39:58 PM »

With this setting turned to "OFF" the char "turns" normally to face forward, without moving the SRB forward.

With it set to ON, it blends the turn forward with the last step of the strafe, looks like that causes the "step forward" you mention.

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Prevent Turning When IDLE
« Reply #7 on: Feb 22, 16, 08:30:30 PM »

Quote
Then again this will most likely all change once we get the game character in.

Thats what happened with us, however, its still good to know where these things take place and how we might use them/customize them, and pass that on to someone else.  I've marked these blocks on our end and made some comments for later use, appreciate you bringing this one up too :)