Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 MannyLectro · Dec 04, 2012 at 02:56 AM · instantiate

Plant Reproduction, Instantiate problem

Hi everyone ! I am learning Unity and Javascript since 3 days now and I need your help for something.

I decided to practice all of what I learned by making a "plant" in unity, that would grow, change model, reproduce and die. For the growing, changing model and dying part everything works find, but I can't seem to make it reproduce.

When I instantiate a new plant from the original one, that new plant is as old as the original one. Any way I can solve this ?


var Vie : float = 60;

var Adult : float =40;

var Dead : float =20;

var Reproduction : boolean = true;

var Plant : GameObject;

function Update () {

Vie -= Time.deltaTime;

if(Vie<=0){ Destroy(gameObject);

}else if(Vie<=Adult){

var Fstep : MeshRenderer = gameObject.Find("PlantYoung").GetComponent(MeshRenderer); Fstep.enabled = false;

var Sstep : MeshRenderer = gameObject.Find("PlantAdult").GetComponent(MeshRenderer); Sstep.enabled = true;

}

if((Vie<=Adult) && (Reproduction)){ var position = Vector3(Random.Range(-10,10), 0, Random.Range (-10, 10)); Instantiate (Plant, position, Quaternion.identity); Reproduction = false;

}

if(Vie<=Dead){ Sstep.enabled = false;

var Tstep : MeshRenderer = gameObject.Find("PlantDead").GetComponent(MeshRenderer); Tstep.enabled = true;

}

}

Comment
Add comment · Show 1
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 ThePunisher · Dec 05, 2012 at 02:27 AM 0
Share

Is this all the code you are using? Post the rest if there's more.

Also, can you format your code correctly by using the button with the binary (0's and 1's) image on it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MannyLectro · Dec 04, 2012 at 12:51 PM

Hi ! Thanks Rob ! But doing that only help for the first generation of plant, but then the next one is the prefab, and I get the same problem again.

Comment
Add comment · Show 1 · 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 ThePunisher · Dec 05, 2012 at 02:10 AM 1
Share

Please use the "add new comment" button for comments. :(

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.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Instantiate: Create Connection 1 Answer

Instantiated gameObjects can't find each other 0 Answers

Done Something Wrong, Don't Know What I've Done? 2 Answers

OnTriggerStay Instantiate Problem (just want a single spawn, but there are multiple) 1 Answer

Client/Server Network Instantiate Problems/Client Can't Connect 0 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