make an object glow when the player walks near it?
Hey, I'm new to unity and for an assignment I want to have an object glow when the character walks near it. I know I need to do something like put a box collider around it that's a trigger, then have a script that whenever the player walks into it it glows, but I know nothing about scripting or triggers. Thanks
Yes, the object should have a Collider component set to IsTrigger = true. What kind of collider is up to you, a box collider would work perfectly well. Just make sure it's convex if using a $$anonymous$$eshCollider.
Then the character object needs a script that registers the trigger collision. If the character consists of multiple GameObjects (multiple children), then the script needs to be on the GameObject that has a non-trigger collider as well as a RigidBody set to Is$$anonymous$$inematic = false.
You use the OnTriggerEnter method to register collisions.
void OnTriggerEnter(Collider collider_other) {
//do something with collider_other.gameObject...
}
The glow part is a little bit more complicated and depends a lot on how you want it to look. there are camera scripts that let you make objects glow, or glow and outline shaders for the object itself, or maybe even different options.
Your answer
Follow this Question
Related Questions
2D shader / lighting like Terraria or Starbound 2 Answers
how can I set Lightmap Scale per object 0 Answers
Particle System (Show particles more where the light is - Rain Falling for example) <- 0 Answers
RealTime Lighting on Heavily Moving Environment: A Trick to Make it Happen (Maybe) 0 Answers
Point Light Source Radius 0 Answers