Answer the question
In order to leave comments, you need to log in
How to make an object turn the collider on and off?
In unity, I'm new, just recently touched on the topic of Raycast2D.
I need to complete the task: There are two beams. One up, one down. The beam pointing up should turn off colliders with the "platform" tag, and the one down should turn them on.
Here's the code I wrote:
RaycastHit2D hitInfoUP = Physics2D.Raycast(transform.position, Vector2.up);
RaycastHit2D hitInfoDOWN = Physics2D.Raycast(transform.position, Vector2.down);
if (hitInfoUP.transform.tag == "platform")
{
hitInfoUP.collider.enabled = false;
}
if (hitInfoDOWN.transform.tag == "platform")
{
hitInfoDOWN.collider.enabled = true;
}
After that, the error
CommandInvokationFailure: Unity Remote requirements check failed
C:/Program Files/Unity/Hub/Editor/2019.4.28f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\platform-tools\adb.exe forward tcp:7201 tcp :7201
stderr[
error: no devices/emulators found
]
stdout[
The code is not doing its job. How can it be solved?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question