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 /
  • Help Room /
avatar image
0
Question by prezio · Dec 03, 2018 at 01:55 PM · multiplayermultiplayer-networkingcheckpointcheckpoints

How to make multiplayer checkpoint's

How is it possible to make multiplayer checkpoints? I want to achive something like that: For example we've got 2 players: 1Player and 2Player. 1Player is faster than 2Player. If 1Player exceeded first checkpoint it appears him second checkpoint. But 2Player only show first checkpoint. Here is my code to boatcontroller

 void Start()
 {
     if (!isLocalPlayer)
     {
         Destroy(this);
         return;
     }
     cameraOffset = new Vector3(0f, cameraHeight, -cameraDistance);
     mainCamera = Camera.main.transform;
     MoveCamera();
     checkpoint1 = GameObject.FindGameObjectWithTag("CheckPoint");
     checkpoint2 = GameObject.FindGameObjectWithTag("CheckPoint2");
     checkpoint3 = GameObject.FindGameObjectWithTag("CheckPoint3");
     checkpoint4 = GameObject.FindGameObjectWithTag("CheckPoint4");
     checkpoint2.SetActive(false);
     checkpoint3.SetActive(false);
     checkpoint4.SetActive(false);
     
     
 }

 void OnTriggerEnter(Collider other)
 {
     
         if (other.tag == "CheckPoint")
         {
             checkpointReached = true;
             checkpoint1.SetActive(false);
             checkpoint2.SetActive(true);
         }
         if (other.tag == "CheckPoint2")
         {
             checkpointReached2 = true;
             checkpointReached = false;
             checkpoint2.SetActive(false);
             checkpoint3.SetActive(true);
         }
         if (other.tag == "CheckPoint3")
         {
             checkpointReached3 = true;
             checkpointReached2 = false;
             checkpoint3.SetActive(false);
             checkpoint4.SetActive(true);
         }
         if (other.tag == "CheckPoint4")
         {
             checkpointReached3 = false;
             checkpointReached4 = true;

         }
     
 }
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "CheckPoint2")
         checkpointReached = false;
     if (other.tag == "CheckPoint3")
         checkpointReached2 = false;
 }


 void Update()
 {
    
     Balance();

     if (Input.GetKey(KeyCode.A))
         ship.RudderLeft();
     if (Input.GetKey(KeyCode.D))
         ship.RudderRight();

     if (forward)
     {
         if (Input.GetKey(KeyCode.W))
             ship.ThrottleUp();
         else if (Input.GetKey(KeyCode.S))
         {
             ship.ThrottleDown();
             ship.Brake();
         }
     }
     else
     {
         if (Input.GetKey(KeyCode.S))
             ship.ThrottleUp();
         else if (Input.GetKey(KeyCode.W))
         {
             ship.ThrottleDown();
             ship.Brake();
         }
     }

     if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))
         ship.ThrottleDown();

     if (ship.engine_rpm == 0 && Input.GetKeyDown(KeyCode.S) && forward)
     {
         forward = false;
         ship.Reverse();
     }
     else if (ship.engine_rpm == 0 && Input.GetKeyDown(KeyCode.W) && !forward)
     {
         forward = true;
         ship.Reverse();
     }
     if (checkpointReached==true)
     {
         checkpoint1.SetActive(false);
         checkpoint2.SetActive(true);
     }

 }
 private void FixedUpdate()
 {
     MoveCamera();
 }
 void Balance()
 {
     if (!m_COM)
     {
         m_COM = new GameObject("COM").transform;
         m_COM.SetParent(transform);
     }

     m_COM.position = COM;
     GetComponent<Rigidbody>().centerOfMass = m_COM.position;
 }
 void MoveCamera()
 {
     mainCamera.position = transform.position;
     mainCamera.rotation = transform.rotation;
     mainCamera.Translate(cameraOffset);
     mainCamera.LookAt(transform);
 }

}

And here is my code to checkpoints private void Start() {

     ship.checkpoint1.SetActive(true);
     ship.checkpoint2.SetActive(false);
     ship.checkpoint3.SetActive(false);
     ship.checkpoint4.SetActive(false);

 }
 void Update()
 {
     
     
     if (ship.checkpointReached == true)
     {
         ship.checkpoint2.SetActive(true);
         Vector3 targetPosition = ship.checkpoint2.transform.position;
         targetPosition.y = transform.position.y;
         transform.LookAt(targetPosition);
     }
     else if (ship.checkpointReached2 == true)
     {
         ship.checkpoint3.SetActive(true);
         Vector3 targetPosition = ship.checkpoint3.transform.position;
         targetPosition.y = transform.position.y;
         transform.LookAt(targetPosition);
     }
     else if (ship.checkpointReached3 == true)
     {
         ship.checkpoint4.SetActive(true);
         Vector3 targetPosition = ship.checkpoint4.transform.position;
         targetPosition.y = transform.position.y;
         transform.LookAt(targetPosition);

     }
     else
     {
         Vector3 targetPosition = ship.checkpoint1.transform.position;
         targetPosition.y = transform.position.y;
         transform.LookAt(targetPosition);
     }
     
 }


Comment
Add comment · Show 4
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 BruceKristelijn · Dec 03, 2018 at 03:31 PM 0
Share

What exactly do you want to have happen with these checkpoints? The code can also be way more dynamically written. But can you please allaborate at what you want to achieve?It helps more and will help people more id people awnsering can give some theory aswell.

avatar image prezio BruceKristelijn · Dec 03, 2018 at 03:48 PM 0
Share

For example we've got 2 players: 1Player and 2Player. 1Player is faster than 2Player. If 1Player exceeded first checkpoint it appears him second checkpoint. But 2Player only show first checkpoint.

avatar image BruceKristelijn prezio · Dec 10, 2018 at 04:13 PM 0
Share

You can always get the checkpoints from the server. Then wehn a players hits checkpoint 1 on the server side send a message updating the checkpoint he is on and a message to the player for displaying the changed checkpoint

Show more comments

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

227 People are following this question.

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

Related Questions

how to split player objects over network? 0 Answers

Multiplayer - Using BroadCast in OnIncomingData function 1 Answer

TrailRender not showing in all clients using Mirror networking 1 Answer

How do i use RPC's to set a object active in the hierarchy for all Players in the room and also how do i synchronize UI events focused on a VideoPlayer (Play, Pause etc.)) 0 Answers

PhotonOnSerializeView() Only working sometimes 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