1
\$\begingroup\$

So I am making an RPG and I am setting up the player. I am trying to trigger an attack animation by pressing a button. I wrote this down and I get an error that says "Expressions in statements must only be executed for their side-effects". I don't know what that means, but it is an error that won't let me play the game without fixing it. I'm not sure where to go from here. How would I fix the error? EDIT: I'm not using Mecanim, nor am I planning on using it.

This is the script. It is in JavaScript (Unity3D).

#pragma strict

var anim: AnimationClip;

function Start()
{
    animation["Sword Slash"].layer = 4;
    animation["Sword Slash"].wrapMode.Once;
}

function Update () 
{

    if (Input.GetKeyDown ("c"))
    {
        animation.Play("Sword Slash");
    }
}
\$\endgroup\$
  • \$\begingroup\$ Playing animation clip that way is not usual anymore. Unity has mecanim now to control animations and keep it in a structured way. I suggest you to use mecanim. Go to : docs.unity3d.com/Manual/AnimationOverview.html It's fun. \$\endgroup\$ – Sourav Paul Jun 19 '16 at 18:00
  • \$\begingroup\$ It doesn't look like the code you've shown contains anything that would trigger the error message you describe. Usually it happens from forgetting the parentheses in a function call or things like that. Did the error message tell you the file & line number where the error occurred? You can usually double-click the message to jump precisely to the problem spot. \$\endgroup\$ – DMGregory Jun 20 '16 at 2:35
  • \$\begingroup\$ DMGregory: I did, and it brings me to line 7 (animation["Sword Slash"].wrapMode.Once;) \$\endgroup\$ – user80678 Jun 20 '16 at 5:34
3
\$\begingroup\$

The line animation["Sword Slash"].wrapMode.Once doesn't actually do anything, and that's why an error is generated, to help you. Maybe you meant to assign by calling animation["Sword Slash"].wrapMode = WrapMode.Once?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.