Sign in to follow this  
johnboy007

Problem with Anim and pickup object

Recommended Posts

I am having a problem when i pickup an object, what happens is when i press the mouse button, the object disapears before the the animation plays to pick up the object.

I am using JavaScript and Unity3D any suggestions?

if(Input.GetMouseButtonDown(0))
{
// play animation
player.animation.Stop("Hands Still");
player.animation.wrapMode = WrapMode.Once;
player.animation.Play("Hands Pickup");

// Add the object to array and disable render
pickupObjects.Add(Object);
Object.renderer.enabled = false;
}

Share this post


Link to post
Share on other sites
Sounds to me like you just need to make sure the animation has been played before you pick up the item, it's hard to tell without knowing how animation.Play is implemented but what I think is happening is that the animation starts playing and immediately after you pick up the item and disable rendering.

Share this post


Link to post
Share on other sites
if(Input.GetMouseButtonDown(0))
{
// play animation
player.animation.Stop("Hands Still");
player.animation.wrapMode = WrapMode.Once;
player.animation.Play("Hands Pickup");

// Add the object to array and disable render
pickupObjects.Add(Object);
[color="#ff0000"][b]yield WaitForSeconds (X);
[/b][/color] Object.renderer.enabled = false;
}


Try using the yield command to hold the script while the animation plays. Replace [b][color="#ff0000"]X[/color][/b] with the number of seconds you want to wait.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this