Loop animation mesh help

Discussions about Coding and Scripting
Post Reply
User avatar
Metalfist
Masterful
Posts: 632
Joined: Sun Jan 03, 2010 3:54 pm
Personal rank: ^,..,^ rawr

Loop animation mesh help

Post by Metalfist »

Ok I start with saying I'm a noob coder. I'm trying to let a mesh (Introdude) play an animation over and over again (and standard UTstuff won't do the job). I saw this code from CTF-Bedrooms, but I could only hardcode 1 animation with it. I wanted to make it so that I can choose which animation I want and here is where my noobness in coding starts.
I wanted to create a string, where you can type the animation you want in the editor.
It then gets send in the spot where the loopanimation is, so you have a variable that can change.
This is the code:

Code: Select all

class Humper1 expands IntroDude;

var() string AnimationChoice; //type which animation you want

function PostBeginPlay()
{
         Super.PostBeginPlay();
	LoopAnim( 'AnimationChoice',0.7,0.1); //put that animation here and loop it
}
But it doesn't work this way. I tried some things, but it won't compile/work properly. So what am I missing? :help:
I want to understand how this all works.
Image
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Loop animation mesh help

Post by Feralidragon »

In UScript you have 2 kinds of character variables:
- name: a "string" but which may only contain alphanumeric characters and underscores (it does not allow spaces or any other character), example: "Foo_23"
- string: the regular string type which accepts any character, example: "Foo is a generic thang..."

In the case of animations, they do not use "string", they use "name", thus the compilation error you're getting is most likely a "type mismatch" error.
Therefore you just need to change your variable type from "string" to "name". :)

As for the usage, it's:
LoopAnim(AnimationChoice, ...
Not:
LoopAnim('AnimationChoice', ...

Remove the single quotes from the variable in LoopAnim.
User avatar
Metalfist
Masterful
Posts: 632
Joined: Sun Jan 03, 2010 3:54 pm
Personal rank: ^,..,^ rawr

Re: Loop animation mesh help

Post by Metalfist »

Thx ferali! It works now :D
Image
Post Reply