Disable a skript from another skript in the same Objekt
First of all, I know that such a question has already been asked, but these answers have not helped me.
So I watched this Youtube Tutorial https://youtu.be/gAB64vfbrhI and I copied the script, but it no longer works because of the version of Unity (I think that's the problem).
So the "Player Collision" should disable the "Player Movement" script and they are in the same Object:
And now i have this code from the Video and the "Player Movement" script doesn't disable itself. Can someone explain to me how it has to be right for it to work using UnityEngine;
public class PlayerCollision : MonoBehaviour
{
public PlayerMovement movement;
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false;
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613004327im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Locking the player movement and fading out when entering a trigger 0 Answers
AddListener issue C# 0 Answers
Need Help with a match 3 style game 0 Answers
Help me ! Unity Mana !,HELP ME MANA! 0 Answers
enabling and disabling components script not working 1 Answer