Hello Guest

Author Topic: anim.currentClip.name problem.  (Read 4965 times)

chobi77

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
anim.currentClip.name problem.
« on: September 08, 2012, 03:45:39 pm »
Hi all,

I am doing a check to see if an animation is playing so i can get Mario to walk after he lands from a jump and make the jump animation stop.

The problem is that the code  i am using does not work, i have seen examples here and they seem to be working for others so i would like to figure out where i am going wrong.

                       
Code: [Select]
if (velocity.x < 0)
{
velocity *= walkSpeed;
if (anim.isPlaying() && anim.currentClip.name != "MarioSmallWalkLeft")
anim.Play("MarioSmallWalkLeft");
jumpEnable = false;
}

the problem is with the if (anim.isPlaying() && anim.currentClip.name != "MarioSmallWalkLeft") line.

the error i am getting is `tk2dAnimatedSprite.currentClip' is inaccessible due to its protection level.

Can anyone shed any light on why this is happening?

Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: anim.currentClip.name problem.
« Reply #1 on: September 08, 2012, 04:00:52 pm »
The one you want is CurrentClip, thats the public property.

chobi77

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: anim.currentClip.name problem.
« Reply #2 on: September 08, 2012, 04:06:38 pm »
Thanks for the quick reply.

I changed it to CurrentClip and now i get this error.

Type `tk2dAnimatedSprite' does not contain a definition for `CurrentClip' and no extension method `CurrentClip' of type `tk2dAnimatedSprite' could be found (are you missing a using directive or an assembly reference?)

any ideas?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: anim.currentClip.name problem.
« Reply #3 on: September 08, 2012, 04:25:35 pm »
Its likely you're using an old version. What version are you on?

chobi77

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: anim.currentClip.name problem.
« Reply #4 on: September 08, 2012, 04:29:56 pm »
version 1.51

:)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: anim.currentClip.name problem.
« Reply #5 on: September 08, 2012, 04:48:47 pm »
Might be a good idea to update, that's an ancient version you've got there...

chobi77

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: anim.currentClip.name problem.
« Reply #6 on: September 08, 2012, 05:14:01 pm »
Oh wow yes, that never occurred to me...

Seems i also have to upgrade Unity to 3.5.5 as well.

Thanks for that, i hope all this works when i finish upgrading.  :)