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 daniel5121 · Feb 11, 2018 at 03:09 PM · 2d2d gameplatformercheckpointcheckpoints

Having troubles with the checkpoints opening on my 2D platformer and its making my sprite dissapear.

I have set up a checkpoint and the sprite of the flag starts of closed but when the character walks through the checkpoint and touches the circle collider the character disappears and when I click on the scene the character is nowhere to be found. Here are some screenshots of what is happening and my code. This is the script for the player:using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour {

 public float moveSpeed;
 private Rigidbody2D myRigidbody;

 public float JumpSpeed;

 public Transform groundCheck;
 public float groundCheckRadius;
 public LayerMask whatIsGround;

 public bool isGrounded;

 private Animator myAnim;


 // Use this for initialization
 void Start()
 {
     myRigidbody = GetComponent<Rigidbody2D>();
     myAnim = GetComponent<Animator>();
 }

 // Update is called once per frame
 void Update()
 {

     isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);

     if (Input.GetAxisRaw("Horizontal") > 0f)
     {
         myRigidbody.velocity = new Vector3(moveSpeed, myRigidbody.velocity.y, 0f);
         transform.localScale = new Vector3(0.4f, 0.4f, 0.3f);
     }
     else if (Input.GetAxisRaw("Horizontal") < 0f)
     {
         myRigidbody.velocity = new Vector3(-moveSpeed, myRigidbody.velocity.y, 0f);
         transform.localScale = new Vector3(-0.4f, 0.4f, -0.3f);

     }
     else
     {
         myRigidbody.velocity = new Vector3(0, myRigidbody.velocity.y, 0f);

     }

     if (Input.GetButtonDown("Jump") && isGrounded)
     {
         myRigidbody.velocity = new Vector3(myRigidbody.velocity.x, JumpSpeed, 0f);
     }

     
     myAnim.SetFloat("Speed", Mathf.Abs( myRigidbody.velocity.x));
     myAnim.SetBool("Grounded", isGrounded);
 }

   void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "KillPlane");
     {
         gameObject.SetActive(false);
     }
 } 

}

here is the script for the checkpoint: using System.Collections; using System.Collections.Generic; using UnityEngine;

public class CheckpointController : MonoBehaviour {

 public Sprite flagClosed;
 public Sprite flagOpen;

 private SpriteRenderer theSpriteRenderer;

 public bool CheckpointActive;

 // Use this for initialization
 void Start () {

     theSpriteRenderer = GetComponent<SpriteRenderer>();

 }
 
 // Update is called once per frame
 void Update () {
     
 }

 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         theSpriteRenderer.sprite = flagOpen;
         CheckpointActive = true;
     }
 }

}

![alt text][2] [2]: /storage/temp/111111-checkpoint-inspector.png alt text

checkpoint-inspector.png (46.5 kB)
player-inspector.png (61.8 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cuttlas-U · Feb 11, 2018 at 03:27 PM

hi; i read your code and saw your screen shots i think i cant find any problem in these;

so the problem must be else where ? if u have "any desk" programm installed i can take a look at your system ;

Comment
Add comment · Show 2 · Share
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 daniel5121 · Feb 11, 2018 at 03:31 PM 0
Share

Thank you for the reply i have got TeamViewer but i could get any desk if needed

avatar image Cuttlas-U daniel5121 · Feb 11, 2018 at 03:33 PM 0
Share

I dont know how much this problem is important for u i usually give this advice if i think the problem is else where ;

sadly $$anonymous$$m viewer is blocked in my country so if u like install Any Desk and send me your id in my gmail : savajjad@gmail.com

good luck

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

209 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

Related Questions

Trying to get bool statement to work in OnTriggerStay2D 1 Answer

"Is Kinematic" required? 1 Answer

Picking up 2D collectables in an order? 0 Answers

How to make bullet move? 0 Answers

Issues with dropping an object on multiple objects separetly - Simple 2d Drag & Drop 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