Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 jammerjar · Jun 18, 2011 at 06:25 AM · vector3lerpinstance

Now I'm over Inflated!

So i have been working on this balloon script and thanks to the help of people here i have now got my balloon appearing all over the place and have them inflating (getting bigger) over time, but...

It only works on the first instance. Every subsequent clone is already big. Now I expect this is cos I am so silly that i dont know how to combine the code properly so I have the get bigger code on my balloon and the create instance on a game object.

So my question is how do i combine these two code so that each instance grows as it is created. Sorry to be such a dummy but im new but learning fast.

My simple instance code

     var projectile : Rigidbody;
     
     function Update () {
     
     if (Input.GetButtonDown("Fire1")) {
     
     var clone : Rigidbody;
     clone = Instantiate(projectile, transform.position, transform.rotation);
     clone.velocity = transform.TransformDirection (Vector3(0, -1, 0) * 12);
     }
     }
     
 




And my scale script

   var bigScale : Vector3 = Vector3(30,30,30);
     var myTime : float = 1.0;
     
     function Update () 
     {
      transform.localScale = Vector3.Lerp(transform.localScale,bigScale,Time.deltaTime * myTime);
 }



A little more help we see me through.

Thanks

Comment
Add comment · Show 2
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 Muzz5 · Jun 18, 2011 at 06:35 AM 0
Share

Try putting the scale script as a seperate script?

avatar image jammerjar · Jun 18, 2011 at 06:41 AM 0
Share

Sorry - should have posted separately. They are separate and on separate object. But I think they both need to be part of the instance script.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Oliver Eberlei · Jun 18, 2011 at 10:02 AM

What do you put into your projectile variable? Is it a GameObject that is already in the scene? Try creating a prefab instead. Otherwise, if the GameObject you clone grows in size, you will clone the increased size aswell.

By using a prefab your newly created clone will always be in its default state, since it never was in the scene and therefore didn't grow before.

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 Bunny83 · Jun 18, 2011 at 12:07 PM 0
Share

Exactly and watch out, if a script that is part of a prefab hold a reference to itself, it will point to the instantiated clone after it's instantiated. So if the instance tries to create another instance it clones the instance and not the prefab.

Some call it a bug, but i guess it's intended behaviour ;) As long as your instantiate script is not part of the prefab itself there's not problem, as long as you assigned the prefab to the variable and not an instance from the scene.

avatar image jammerjar · Jun 18, 2011 at 01:22 PM 0
Share

Hey thanks - i am putting the projectile var onto an empty game object. The Variable is a cube (just for testing) that has the scale object on. So will try with a prefab and let yo know how it goes. Its 1.00am now so will have to wait till the morning. Cheers.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Vector3.lerp doesn't work when level is loaded 1 Answer

Vector3.lerp doesn't work in local position 1 Answer

Vector3.Lerp does not linearly interpolate, any ideas? 1 Answer

How the heck does Mathf.Lerp work? 2 Answers

Lerp jump using input won't convert to world space 1 Answer


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