3rd Person scripting start (beginner)

Hello, I am new to this forum and game engine. I have been trying alot of the tutorials online and found them quite helpful, but I seem to have ran into alittle problem with a script for 3rd person.

I have tried to edit the script to get the result for what I need with little success. I thought I would share my problem and perhaps not only help myself, but for those later that ask the same question.

What I have and am trying to do is follow the 3rd person tutorial with the Lerpz character, but I wish to change the character to one of my own. Problem is not with changing the mesh it is with the animations. I have 6 animations for what I wanted. They are " Idle, Walk, Jump, Jumpland,Fire, and Die " . Walk works great, but everthing else seems to be a problem. When I press jump it does not use the first part of the jump cycle. It does do the jumpland cycle. However the animation does not stop looping.

So my question would be, how do I go about fixing this? Or even how to create the script for the ground up?

Attached are the two scripts that are causing me the problem. Unedited.

408689–14135–$ThirdPersonPlayerAnimation.js (3.38 KB)
70743–2651–$thirdpersoncontroller_109.js (12.7 KB)

The Lerpz scripts can be a bit much when first learning scripting, at least they were for me. I found this tutorial quite helpful when I first started: http://www.unitylabs.net/tutorials/character-controllers/third-person-character-controller

It pretty much strips down what Lerpz has to just basic movement with idle. walk, and run. If you’ve gotten everything else taken care of (Camera, character controller, terrain, etc…) you can skip to the 4th part which has the script. From there, you can look back to the Lerpz scripts to see how other things are implemented, and build from there. Doing that helped me learn better how each line works, than trying to start solely from Lerpz’ scripts. Anyway, that’s just my suggestion. Good luck! :slight_smile:

Thank you! I have been just going with the tornado twins on the worm game idea, but I made some models with animation to make it look better. Just a learning tool at this point.

I will take the time to check out the tutorials on the site you gave.

So far, all is good with this, but I have ran into some problems. I have been only able to add one animation and that loops. Using the tutorials I made a script that is working great, I just want a way to increase certain things like the animations, of course, but also sounds for body hits and death. Also need a way to make to make a script for going to the next level after all enemies are gone, but it seems there is no real tutorial on that. What I have done is attached my scripts for what I have done. You will see that I have done some of my own editing from what the tornado twins had suggested.

I realize that this inot a work in progress thread, but I thought it might nice to show what I am doing. I know sometimes seeing a pic of what someone is doing can show how dedicated a person is.

409574–14180–$MoveAround.js (1.8 KB)
409574–14181–$healthControl.js (819 Bytes)
409574–14182–$turretControl.js (998 Bytes)
409574–14183–$turretCollision.js (371 Bytes)

Glad to see you are making progress! For animations, I would create another script that handles just those. Scripting animations generally depends on how you set up the character controller. Depending on what space you are moving in, you will need to check for input, then do an animation.CrossFade accordingly. If you need help implementing a particular animation send me a message if I forget to check back here, and I’ll see if I can help. And to switch to the next level, you use:

Application.LoadLevel(1);

where the 1 is the scene number that is set in your build settings (file - build settings). Each scene that you want to be able to load has to be added to that.

Thanks! Here is a small demo of my progress. I will start on the animations tomorrow.

http://www.mediafire.com/?61vg0b6rdo4p1by

Some things I did notice is when all the turrets are destroyed, the game over screen is fast to pop up. I will need to figure out how to slow that down as well as implementing a score board. Also I noticed that the if I say used the same scene for the game over menu as the main menu, the main camera needs to be rotated 180 degrees. And only for the game over screen, but if you leave them along the main menu camera will rotate 180 degrees in the build game. It’s odd, but I can work with that.

Enjoy!

I think I just gave you guys the download to the messed up windows version, so here is a web player that is fixed.

http://www.mediafire.com/?4wxuexyxwdq3gtt

Or if you just want to see what I have done, here is a link to the video.

http://www.youtube.com/watch?v=xvPMinpeX5w

Enjoy!

Wow ts going great men good luck

Thanks!

I have another question on a script. I have made an animation control script, but I need to include a few things.

Here’s the script to look at.

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

function Start()
{
    charController = GetComponent(CharacterController);
    animation.wrapMode = WrapMode.Loop;
}


function Update () 
{
    if(charController.isGrounded == true)
    {
        if(Input.GetAxis("Vertical") > .1)
        {
            animation["Walk"].speed = 1;
            animation.CrossFade("Walk");
            walkSpeed = 1;
        }
        else if(Input.GetAxis("Vertical") < -.1)
        {
            animation["Walk"].speed = -1;
            animation.CrossFade("Walk");
            walkSpeed = 1;
        }
        else
        {
            animation.CrossFade("idle");
        }

        // Create an animation cycle for when the character is turning on the spot
        if(Input.GetAxis("Horizontal")  !Input.GetAxis("Vertical"))
        {
            animation.CrossFade("Walk");
        }


        transform.eulerAngles.y += Input.GetAxis("Horizontal");

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

    }

}

What I want to add is a jump animation, a firing animation and a die animation. The jump animation has a start and a an end. Also need to add more control to the death respawn, meaning the time to spawn is immediate and I want it to play the death animation and slow down the respawn.
Now that I am thinking it, I do want to give the turret control script a player within a certain distance before it fires. Looking at my control script above, what do I need to make that happen?

I have also written some new code to display the hits the player is taking. Here is a pic of that progress.

Nice worminator i wish you luck, maybe you could point me to a good learning how to shoot in a 3rd person game tutorial i’m a newb but I’ve gotten far by looking at tutorials. Any help thanks

This site doesn’t seem to be up anymore? Does anyone have these tutorials available? I’d really like to check them out. Thanks.