Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 unity_l5gXvpRu2FDjmQ · Mar 17, 2019 at 08:49 AM · clonepowerupswitch-casemarioswitch characters

Mario Powerups Switching problem,Mario PowerUps Switch problem

Hello, my name is Reno. I am a beginner in programming and I want to program a game. My first game is a Mario Clone. I programmed it so that there is a game object for each powerup form. Each time Luigi touches the mushroom, the game object has to be changed. My problem is that when Luigi touches the mushroom, the gameobjects are switching nonstop per milisecond. Its kinda hard to explain. alt text

I hope you understand what I mean. When Luigi touches the mushroom he should switch with the big gameobject and stay in that form. Now they are switching betwen those two.

This is my Code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class Collecter : MonoBehaviour
 {
     public GameObject LilMario, BigMario;
 
     int whichMarioIsOn = 1;
 
     void Start()
     {
         
         LilMario.gameObject.SetActive(true);
         BigMario.gameObject.SetActive(false);
         
     }
     void Update()
     {
         SwitchMario();
     }
 
     public void SwitchMario()
     {
         switch (whichMarioIsOn)
         {
             //Default case
             case 1:
 
                 whichMarioIsOn = 1;
 
                 LilMario.gameObject.SetActive(true);
                 BigMario.gameObject.SetActive(false);
                 break;
             //Big case
             case 2:
 
                 whichMarioIsOn = 2;
 
                 LilMario.gameObject.SetActive(false);
                 BigMario.gameObject.SetActive(true);
                 break;
          }
     }
 
 
 
     private void OnCollisionEnter2D(Collision2D other)
     {
         if (other.gameObject.tag == "Pilz")
         {
             whichMarioIsOn = 2;
             Debug.Log("2 aktiv");
             Destroy(other.gameObject);
             
         }
     }
 
     
 
 
 
 
 
 
 
 
 }
 

I think the problem is in the update method. I hope you understand it and can help me. Thx for every answers have a nice day !,Hello, my name is Reno. I am a beginner in programming and I want to program a game. My first game is a Mario Clone. I programmed it so that there is a game object for each powerup form. Each time Luigi touches the mushroom, the game object has to be changed. My problem is that when Luigi touches the mushroom, the gameobjects are switching nonstop per milisecond. Its kinda hard to explain. alt text

I hope you can understand what I mean. I want that when Luigi touches should the bigLuigi appear and stay. But now both are switching nonstop.

This is my Code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class Collecter : MonoBehaviour
 {
     public GameObject LilMario, BigMario;
 
     int whichMarioIsOn = 1;
 
     void Start()
     {
         
         LilMario.gameObject.SetActive(true);
         BigMario.gameObject.SetActive(false);
         
     }
     void Update()
     {
         SwitchMario();
     }
 
     public void SwitchMario()
     {
         switch (whichMarioIsOn)
         {
             //Default case
             case 1:
 
                 whichMarioIsOn = 1;
 
                 LilMario.gameObject.SetActive(true);
                 BigMario.gameObject.SetActive(false);
                 break;
             //Big case
             case 2:
 
                 whichMarioIsOn = 2;
 
                 LilMario.gameObject.SetActive(false);
                 BigMario.gameObject.SetActive(true);
                 break;
          }
     }
 
 
 
     private void OnCollisionEnter2D(Collision2D other)
     {
         if (other.gameObject.tag == "Pilz")
         {
             whichMarioIsOn = 2;
             Debug.Log("2 aktiv");
             Destroy(other.gameObject);
             
         }
     }
 
     
 
 
 
 
 
 
 
 
 }
 

I think the problem is in the void Update Method. I hope you can help me. Thx for every Answer.

sefsefsefswef.png (44.3 kB)
sefsefsefswef.png (44.3 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

99 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

Related Questions

SMB Power Up Animation - Player Position Issue 1 Answer

Instantiate(this.gameObject) causing crash 2 Answers

Instantiate Clones Itself - Rather than Prefab 0 Answers

send SCORE from OBJECT(clone) to other file 3 Answers

How to follow clone object with camera. 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