Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
This question was closed Nov 13, 2021 at 01:46 PM by unity_418scarlet for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by unity_418scarlet · Nov 12, 2021 at 04:16 PM · collisionmovementrespawn

Player movements go wrong when respawning after collision with enemy

Hello Ladies & Gents Yes , before posting this i spent a day and half trying and looking for answers but the one I am looking for I did not find it.

I have player moving left and right using Horizontal axis input , while it continuously move forward with transform.Translate(0,Yvalue,0);

Everything goes fine till the player collides with an enemy or enemy bullet. It seems that the player kind of acquire the movements of the enemy or it start to rotate without input once it respawn. I followed some instructions found in the forums and after the collision the player start from the starting position I want but the movements are not the ones of before but all seem casual and independent from input , what I am doing wrong? thank you. EDIT : I have tried also to use individual key down but the result is baffling cause the player, only after the first respawn seems to be influenced by external forces which i do not understand Collision script :

 private void OnCollisionEnter2D(Collision2D collision)
     {
         if (collision.gameObject.tag == "Lake")
         {
             deathAndLives.lives--;
             
             StartCoroutine("Respawn");
 
         }
     }
            public  IEnumerator Respawn()
             {
                 gameObject.GetComponent<Movement>().enabled = false;
                 gameObject.GetComponent<Renderer>().enabled = false;
               
                 gameObject.GetComponent<CapsuleCollider2D>().enabled = false;
         
 
                 var objectPOS = transform.position;
                 GameObject Explosion = Instantiate(deathVFX, objectPOS, Quaternion.identity);
                 Destroy(Explosion, 0.7f);
         
                 yield return new WaitForSeconds(1f);
                 transform.position = new Vector3(xstart, ystart, zstart);
         
                 gameObject.GetComponent<CapsuleCollider2D>().enabled = true;
                 gameObject.GetComponent<Renderer>().enabled = true;
                 gameObject.GetComponent<Movement>().enabled = true;
     }

The movement script :

 public class Movement : MonoBehaviour
 {
     [SerializeField] public float steering; 
     [SerializeField] public float speed; 
    
 
   
     void FixedUpdate()
     {
         Move();
     }
 
     private void Move()
     {
         float steeramount = Input.GetAxis("H") * steering;
         transform.Rotate(0, 0, steeramount * Time.deltaTime);
         transform.Translate(0, speed * Time.deltaTime, 0);
     }
 }
Comment
Add comment · Show 1
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 bdubbert · Nov 12, 2021 at 05:23 PM 0
Share

Do you have a rigidbody on your character? If so have you tried setting IsKinematic to true?

1 Reply

  • Sort: 
avatar image
0

Answer by unity_418scarlet · Nov 13, 2021 at 01:45 PM

hello bdubbert , thank you, i did but after that there were no collisions between the player and the rest of the things. I just solve it ( it seems so) taking away these
gameObject.GetComponent().enabled = true; gameObject.GetComponent().enabled = true; gameObject.GetComponent().enabled = true;

and destroy the player and instantiate it after the death.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

240 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 avatar image 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

Cannot move FPSController after respawning at a spawn point. 1 Answer

move camera when it collides with a trigger 1 Answer

Player object falling through game environment, collision not detected with ground 0 Answers

need help with enemy respawn 2 Answers

Alternatives to CharacterController.Move to drive a car 1 Answer


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