• Advertisement
Sign in to follow this  

Problem with Anim and pickup object

This topic is 2418 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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"]yield WaitForSeconds (X);
Object.renderer.enabled = false;
}


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement