Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
cheezy

UNET Spawn/Instantiate Object

Question

Heyho!
I really need some help on a very basic task. I cant seem to figure out how to spawn an Object on all Clients + Host.
The results on google trying to find some easy tutorial are confusing. Some are saying youd have to use only NetworkServer.Spawn() some are saying youd just have to call a Command and Instantiate a GameObject within that. Nothing seems to work.

Could anyone please help me?

 

Please login or register to see this code.

 

The Behaviour i want to achive is that if the Player enters the Trigger on every Client + Host a particle effect should be spawned. (pickupEffect GameObject)
Also.. how would i go ahead and delete it after say 2Seconds?
Before i could use Destory(go, 2.0f);

I would appreciate any hints or answers.

Thanks! Arne

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Okay finally i got it to work in a simple test scene.
 

Please login or register to see this code.

I have no idea exactly why this works but it does. If anyone new to Unet is reading this.. dont forget to register the prefab  in the NetworkManager.

Share this post


Link to post
Share on other sites

  • 0

Hi,

 

the way Unet works is more like authoritative network. That means the Server should be the master of such tasks.

You need 2 Functions:

Please login or register to see this code.

If you have more questions, you can ask me :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...