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 Biendeo · Sep 22, 2010 at 11:36 PM · texturevariableparticlevalue

Help on a Power-Up Sequence

What I am attempting to do is to place a 3D model of a helium tank in the air, and when the player touches it, it disappears, a cloud of smoke pops up in front of the player, and when the smoke disappears, the player has changed colour and can jump higher than before.

I'm only quite novice at scripting, and all I have been able to accomplish is to get the helium tank stay in the air, and when the player touches it, it disappears. I have been trying in vain to get the rest to work though, but I don't know what to look for.

My character's jumping value is in another script that is attached to the player. I was thinking of using two functions in the one script to use one action after the other, but I could not get it to work.

What I'm looking for is how to activate these actions properly in order. I think I know what to do for the cloud of smoke (just a particle system that appears for a second...?), but I don't know how to script it in.

Hope you guys can help! :D

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 Heratitan · Sep 23, 2010 at 02:33 AM

The easiest way I could see doing this is having a script on the helium tank so when the player touches it it starts of a everything.

For the particle system you would probably have a particle system attached to the helium tank and activate it for a few seconds the deactivate it like this:

var cloudOfSmoke : GameObject;

function OnTriggerEnter(c : Collider) { cloudOfSmoke.SetActiveRecursively = true; }

Then for the color you would just change the color of the material that is on the player, so:

var thePlayer : GameObject;

thePlayer.renderer.material.color = Color.red;

then last for the jumping higher you would tell the jumping script to execute a function that increases the variable to what you want, so:

var thePlayer : GameObject;

var pl : InsertScriptWithJumpingHere = thePlayer.GetComponent(InsertScriptWithJumpingHere); pl.RaiseJumpAmount();

This would be the receiving function inside of the script with the jumping variable:

function RaiseJumpAmount(){
     jumpvariable = 5;
}

Hope that helps.

(Edit)

Ok, so for the new version I just combined it into one script.

This is the main script attached to the helium tank, you will have to put the name of the movement script you are using where I put MyFPSWalker.

var cloudOfSmoke : GameObject; var thePlayer : GameObject; var thePlayerGraphic : GameObject;

function OnTriggerEnter(c : Collider) { var pl : MyFPSWalker = thePlayer.GetComponent( MyFPSWalker );

 cloudOfSmoke.SetActiveRecursively(true);
 thePlayerGraphic.renderer.material.color = Color.red;
 pl.RaiseJumpAmount();
 yield WaitForSeconds(3);
 cloudOfSmoke.SetActiveRecursively(false);
 yield WaitForSeconds(10);
 thePlayerGraphic.renderer.material.color = Color.green;
 pl.ResetJump();

}

And these functions should be added to the end of your movement script:

function RaiseJumpAmount(){
     jumpspeed = 16.0;
     gravity = 10.0;
}
function ResetJump(){
    jumpspeed = 8.0;
    gravity = 20.0;
}

Depending on what your gravity and jumpspeed are, you want to raise the jumpspeed and cut the gravity in half. Then in ResetJump they should return to normal.

Feel Free to ask, if you have anymore questions.

Comment
Add comment · Show 3 · 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 Biendeo · Sep 24, 2010 at 06:30 AM 0
Share

I'm not that great at scripting, and following your guide, I cannot seem to get it to work. I seem to be activating the smoke whenever I hit the space bar, my character will not change colour, and the script will not change. Also, I cannot seem to set any variables outside the script in the inspector. Why is that?

avatar image Heratitan · Sep 24, 2010 at 09:02 PM 0
Share

I'm not sure, but I will do some testing and see what the problems might be.

avatar image Heratitan · Sep 24, 2010 at 09:38 PM 0
Share

That should work, I added something to reset it after a certain amount of time, like a power-up, you can take that out if you want, just take out:

 yield WaitForSeconds(10);
 thePlayerGraphic.renderer.material.color = Color.green;
 pl.ResetJump();

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

No one has followed this question yet.

Related Questions

How to get a value from an array within another script. 1 Answer

When passing a value it becomes null 0 Answers

Script for blowing to a particle system 0 Answers

change bar position 1 Answer

How do i disable a script from a different script? 5 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