- Home /
Highlighting background triggered from a 3d model
Hi Guys,
I am fairly new to unity and am trying to figure out how to trigger a game object (this has the highlight script) that highlights itself. Right now the problem is that when i hover over the gem (3d model) i don't trigger the game object that highlights itself (grid tile).
[file A]
At present the gem is highlighted like this:
public void Highlight()
{
m_isHighlighted = true;
renderer.material.color = m_highlightColor;
}
This just highlights the gem, but I want to highlight its background.
I made another game object and place it on the current tile and added this highlight script to it:
[File B]
using UnityEngine;
using System.Collections;
public class HighlightTile : MonoBehaviour {
private float blueMultiplier = 3.50f;
private float redGreenMultiplier = 0.50f;
private Color originalColor;
// Use this for initialization
void Start () {
originalColor = gameObject.renderer.material.color;
}
void OnMouseEnter()
{
AddHighlight();
}
void OnMouseExit()
{
RemoveHighlight();
}
public void AddHighlight()
{
float red = originalColor.r * redGreenMultiplier;
float blue = originalColor.b * blueMultiplier;
float green = originalColor.g * redGreenMultiplier;
gameObject.renderer.material.color = new Color(red, green, blue);
}
public void RemoveHighlight()
{
gameObject.renderer.material.color = originalColor;
}
}
Ideally I would like to highlight the gem and the grid in the background. Any feed back is appreciated, thanks
Thank you for this sir!
Anyway, Im currently using Unity4 for my thesis, a firstperson view game. Is it possible to highlight the object when it is available to hit? I mean, when it is on ranged of my character's mallet? Like in other games when you're about to loot items it highlight the object.
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
2D Sprite Background Rendering 1 Answer
OnTriggerEnter not working on terrain in 3.5 beta 0 Answers
Color custom editor window ? 2 Answers