Adding another idle

Hi all,

I’m trying to learn JS in Unity, specifically trying to learn character controls at the moment. I made a swordsman toon and got him attacking, moving and attacking while moving. He currently has an idle while standing but I’d like to add a kneeling or crouched posture idle. I’d like him to go into a kneeling position when a button is pressed and stay in that position, go into an idle and/or be able to do my strikes. Stand when another key is pressed.

The script I’m using:

private var walkSpeed : float = 1.0;
private var gravity = 100.0;
private var moveDirection : Vector3 = Vector3.zero;
private var charController : CharacterController;

function Start ()
{
// Set all animations to loop
animation.wrapMode = WrapMode.Loop;
// except striking
animation[“backhand2”].wrapMode = WrapMode.Once;
animation[“forehand2”].wrapMode = WrapMode.Once;

charController = GetComponent(CharacterController);

// Put idle and walk into lower layers (The default layer is always 0)
// This will do two things
// - Since strike and idle/walk are in different layers they will not affect
// each other’s playback when calling CrossFade.
// - Since srike is in a higher layer, the animation will replace idle/walk
// animations when faded in.
animation[“backhand2”].layer = 1;
animation[“forehand2”].layer = 1;

// Stop animations that are already playing
//(In case user forgot to disable play automatically)
animation.Stop();
}

function Update () {
// Based on the key that is pressed,
// play the walk animation or the idle animation
if (Mathf.Abs(Input.GetAxis(“Vertical”)) > 0.1)
animation.CrossFade(“shuffle”);
else
animation.CrossFade(“mididle”);

// Strikes
if (Input.GetButtonDown(“Fire1”))
animation.CrossFadeQueued(“backhand2”, 0.1, QueueMode.PlayNow);

// Srikes
if (Input.GetButtonDown (“Fire2”))
animation.CrossFadeQueued(“forehand2”, 0.1, QueueMode.PlayNow);

// Calculate the movement direction (forward motion)
moveDirection = Vector3(0,0, Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);

moveDirection.y -= gravity * Time.deltaTime;
charController.Move(moveDirection * (Time.deltaTime * walkSpeed));

}

I’m really new to scripting and the above was copy pasted/mashed together from various tutorials that I’ve been studying. I tried adding another If else line but It either loses the movement, just kneels and go back to standing when striking or breaks it entirely.

Any help on how to add a kneeling idle to the above or links to JS formatting would be greatly appreciated.

Thanks,
K3D

Anyway. I may very well have missed something, a tutorial or page somewhere out there that would make it all click for me - but I’ve been looking everywhere and finally just broke down and gave up. Could you post a fairly simple step-by-step for after I have dimerocker’s API installed (shows up in the menu, I have my secret-token entered, I see the “dimeRocker arcade” object in my Hierarchy in my project, and the “dimeRocker Listener” under that…

Now say I look at the sample code for “Displaying User Information” from the docs.dimerocker.com site (Examples/Local User Example from the left-side menu on your documentation site)…

Angila, if you have a question, start your own thread. Not sure why you’re resurrecting old ones.

You’re looking at the wrong documentation. For the Arcade you want to go here http://developer.dimerocker.com/docs. We’ll put a redirect on docs.dimerocker to resolve this confusion.

After 4 weeks I thought I finally got an answer to my question. lol.