error CS0103: The name `collidedwith' does not exist in the current context
Hi everyone First of all I wanna thank everyone who put effort in helping others in solving scripting problems. Relly appreciate the hand :D.
Second, I made a script as a goal in the scene and attached it to the game object, the code is like this
// Starts from here
void OnTriggerEnter (Collider collider) { GameObjectcollidedwith = collider.gameObject;
if (collidedwith.tag == gameoject.tag)
{
GetComponent<Light>().intensity = 0;
Destroy(collidedwith);
}
}
but I get an error telling me : error CS0103: The name `collidedwith' does not exist in the current context
so please what am I supposed to do ?
Answer by Jawchewa · May 10, 2017 at 01:34 AM
Well, I noticed a couple of small issues that might be causing a problem like this. First of all, it looks like you might be missing a space in your collidedwith definition. So instead of this:
GameObjectcollidedwith = collider.gameObject;
make it this:
GameObject collidedwith = collider.gameObject;
Also, you have gameObject spelled wrong. Change it from gameoject.tag
to gameObject.tag
Other than that, it looks fine to me, so let me know if that was the issue.
Your answer
Follow this Question
Related Questions
How to create a script for a vehicle fuel? 0 Answers
ArgumentOutOfRangeException is occuring when it shouldn't 0 Answers
Manual GUI Refresh 0 Answers
unity doesnt recognise quaternions 0 Answers
How can i make my spaceship to land automatic on the Base ? 1 Answer