• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by FinKone · Jul 21, 2013 at 08:31 PM · ragdoll

Replacing object with dead ragdoll (need to keep color)

Ok I just can't really come up with a simple concept here on how to handle this... but heres what I have going on.

my AI is randomly generated with a color, the legs and chest (shirt and pants) are the only thing that get a color change to make them appear different from one another.

I change the color using renderer.material.color (using a random range C#) My issue is, figuring out how to store the color, having the object delete (without loosing the color) and creating the ragdoll with the new color. The only solution I can see here is to make some type of death manager object that stores colors of specific objects, send a message to the manager with the color, and then grabs the color with the ragdoll I'm creating and on start change the color...?

This idea seems like over kill but logically I can't really think of anything else.

So to recap - I don't need help destroying or instantiating the ragdoll, the random color is a child script attached to the chest and legs of the hardbody AI, the ragdoll AI has the same chest/leg child object I just can't figure out a simple way to get the random color form that object I'm destroying, to the one I'm creating...

Syntax is kind of killing me to because I'm a bit confused on passing a color (3 floats?).

Any tips or advice would be nice guys. Thanks as always.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Jamora · Jul 21, 2013 at 08:54 PM

Unity has a Color class, which you can use. Create a getter in your script that returns the color you want to pass. Before you destroy the gameobject(s), create a disabled ragdoll and call the getter from its script. Finally destroy the gameobject(s) and enable the ragdoll.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FinKone · Jul 21, 2013 at 09:06 PM 0
Share

Ahh yea seems I was also forgetting "ToString" also which I should have thought about. I'll be checking into it. Didn't think to disable the ragdoll for a second or two to pass the information then destroy. Thanks. I'll let ya know how it goes.

avatar image FinKone · Jul 22, 2013 at 02:33 AM 0
Share

Hey Jamora I ended up doing this - just wondering what you think of it... also sorry for bad spacing...

 In my health script (Attached to AIPED parent)
 
 public GetColorLegs sendLegs;
 
 public GetColorChest sendChest;
 
 public RandomGen chest;
 
 public RandomGen legs;
 
 public Color cLegs;
 
 public Color cChest;
 
 in update function - if health lower then or equal 0
 
 cChest = chest.currentCol (color in random gen attached to chest obj)
 
 cLegs = legs.currentCol(same, diff object)
 
 sendLegs.Legs = cLegs; (Script attached to Ragdoll prefab child leg obj)
 
 sendChest.Chest = cChest; (Script attached to Ragdoll prefab child chest obj)
 Death();



At first I was using a deathmanager kind of half way to hold, and then send the information - but if feels like there might be a better way? Trying to learn the most I can at the same time.

Either way thumbs up for the help ya kick started my brain.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to connect ragdoll character to an object ? 1 Answer

Why do both Ragdoll and Animator are working at the same time ? 1 Answer

Configurable joint axis aren't working with local space 0 Answers

How to easily create a ragdoll with configurable joints? 0 Answers

GUI script problem 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges