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 Izlhandae · Sep 06, 2012 at 08:51 PM · instantiatenetworkvariablesendmessagebomb

Cast a variable over intentiated gameObjects

Hello commUnity ;D

Here's my problem : I'm programming a multiplayer (network) Bomberman, and i'm getting stuck on a simple bomb x_x A player can drop a bomb, which wait a certain time before spawning explosions and destroy itself.

The explosion move one case forward (all the explosion are spawned with the good rotation) and do the same as the bomb : spawning another explosion (range) and destroying (all that in the same frame). The problem is that I can't put a variable "Power" and give it to each explosion, that will decrease it each time they spawn another one, so that I can control the range of the explosion (like in an old school Bomberman).

Here is the two scripts involved in this behavior: BombScript:

 var blast : Transform;
 var power : float = 2;
 private var rotationright = Quaternion.identity;
 private var rotationleft = Quaternion.identity;
 private var rotationdown = Quaternion.identity;
 function Start(){
 networkView.RPC("DestroyIt",RPCMode.AllBuffered);
 rotationdroite.eulerAngles=Vector3(0,90,0);
 rotationgauche.eulerAngles=Vector3(0,-90,0);
 rotationbas.eulerAngles=Vector3(0,180,0);
 }
 function Update () {
 }
 
 @RPC
 function DestroyIt(){
 yield WaitForSeconds(2);
 //Network.Instantiate(blast,transform.position,transform.rotation,3);
 //Network.Instantiate(blast,transform.position,rotationright,3);
 //Network.Instantiate(blast,transform.position,rotationleft,3);
 Network.Instantiate(blast,transform.position,rotationdown,3);
 blast.gameObject.SendMessage("Power",power,SendMessageOptions.DontRequireReceiver);
 //Destroy (gameObject);
 }

And the explosion Script :

 private var exploded : boolean = true;  
 var blast : Transform;  
 private var power : float; 

 function Start(){    
 transform.position += transform.forward;    
 networkView.RPC("Explode",RPCMode.AllBuffered);    
 }
 
 function Update () {
 Debug.Log(power+"is the power");
 }
 
 function OnTriggerEnter(collision : Collider) {
 if(collision.gameObject.tag =="Player"){

collision.gameObject.transform.SendMessage("TakeExplosion",exploded,SendMessageOptions.DontRequireReceiver);
} }

 function Power(info : float){ 
 power = info; 
 }
 
 @RPC   
 function Explode(){   
 Network.Instantiate(blast,transform.position,transform.rotation,4);  
 yield WaitForSeconds(0.2);  
 Destroy (gameObject);   
 }

alt text

And here a little fluffy drawing that sums up my goal ^^ Thank you, any help is appreciated :p (Btw, forget my not so good english, i'm French +_+)

explosion.png (261.4 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

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

Related Questions

How to create a object that can only be seen by one player? 0 Answers

Setting the variable on a GameObject to be instantiated (not yet existent) cs and js 2 Answers

Help! My projectile just falls to the ground :( 1 Answer

Assigning gameobject to an instantiated prefab through script? 2 Answers

sync tags through network? 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