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  
lucian112

Object didn't spawn

Question

Hi,i try to make a battle royale. I ;m copy paste :( script from video,and smth going wrong. My plane didn't spawn like in video. And i copy perfect and do it perfect.here my scripsts and here video:

StartLogic:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class StartLogic : NetworkBehaviour
{
    public int playersNeeded;
    public NetworkManager NM;
    public GameObject Plane;

    private void FixUpdate()
    {
        if (NM.numPlayers == playersNeeded)
        {
            int Rot = Random.Range(0, 360);
            GameObject NewPlane = Instantiate(Plane, Vector3.zero, Quaternion.Euler(0, Rot, 0));
            NetworkServer.Spawn(NewPlane);

            PlaneController PC = NewPlane.GetComponent<PlaneController>();
            PC.enabled = true;
            PC.Moving = true;
            Destroy(this);
        }
    }
}
 

 

PlaneController: 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlaneController : MonoBehaviour
{
    public bool Moving = false;
    [SerializeField] private float speed;
    [SerializeField] private GameObject Plane;

    private void FixUpdate()
    {
        if (Moving = true)
        {
            Plane.transform.Translate(transform.localPosition.x - speed, transform.localPosition.y, transform.localPosition.z);
        }
    }
}
 

 

I didn't know if i do something wrong,i retry 2 times and the same result

 

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 1

if(Moving == true), not if(Moving = true). FixedUpdate, not FixUpdate. You said you copied it perfectly but there’s those issues so obviously it’s not copied perfect. If it works in the video and not for you, it’s a mistake you made, not the author

 

Make sure FixUpdate is changed to FixedUpdate on both scripts, not just one

  • Thanks 1

Share this post


Link to post
Share on other sites

  • 0
Please login or register to see this quote.

No resolves. Plane didn't spawn. I make exactly like in video... Any ideas?

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

thanks... sorry for my mistakes and logic. I need to be more patient i think. Thanks again! 

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...