I have made a 3D model that i have inserted into Unity. Now, i want to make this model obtainable/Pickupable. I have a script for interaction, i just need to know how to make it Trigger. How should i do? Help will be great
If you wonder what the 3D model is, its a Scroll
OnMouseDown?
What do you mean with OnMouseDown?
You need a few things for this to work.
In order to get the best help you will have to explain what you want to happen.
For example:
- I want the scroll to become available once I go over it/through it.
Okay, I have the 3D Model (Scroll) and i want to pick it up. I have the RaycastScript so it should be working. The video i saw how todo the Raycast script he sayd that the item had to be Trigger i believe. And obviously it has to be a GameObject. The meaning of the game im making is to find 8 scrolls and pick them up. Hope that explained.
So slenderscroll
Yes. I guess thats the best explaination. Maybe not 8 but thats a good amount.
There is a checkbox in the collider component.
The problem is that i you cant make the Scroll trigger if its not in a GameObject. And if i make a game object and put the scroll in it, and make it trigger, only the cube reacts to it (Raycast,Interaction Script)
You can add a box collider to the Scroll. Select the scroll, go to Component / Physics / Box Collider.
Everything you add in your scene is a Gameobject.
On a related note: your questions betray the fact that you are not familiar with the Unity Editor. I recommend following some simple tutorials to get a basic understanding of the framework. It will make going forward 10 times easier.
Yes its true Im new to the unity editor. Btw i did as you sayd with the box collider and made it trigger, but with the script i have, i did Component / Script / Interact (Whats the script is called) And the scroll dosent become red (Highlighted) as it should be. When i made a Cube and added the script it does. I want it to work like that. If you dont have time/want to answer this i would be glad if you could send/show me a simple tutorial for that.
The script you mention isnโt standard, I have no idea what it contains. If you post it here (use code tags) I can help.
using UnityEngine;
using System.Collections;
public class Interact : MonoBehaviour
{
public GUIText target;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
renderer.material.color = Color.white;
}
public void OnLookEnter()
{
renderer.material.color = Color.red;
target.text = "Press E to interact";
}
}
Its supposed to make a item highlighted red and then white again when my crosshair in the middle is on it. Yes i made a crosshair.
And the Raycast Script:
using UnityEngine;
using System.Collections;
public class Select : MonoBehaviour {
public RaycastHit hit;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(ray, out hit, 10)){
if (hit.collider.gameObject.GetComponent<Interact>() != null){
hit.collider.gameObject.GetComponent<Interact>().OnLookEnter();
}
}
}
}
What type of material do you have on the scroll?
None (Physic Material)
We are talking about rendering materials, not physics material. (Do you see why following a simple tutorial would do wonders).
Your material needs to have a color component.
The Box collider to the Scroll has None (Physic Material) and i dont know how to change that cause when i press the wheel to the right of the material its only like Rubber, wood etc.
And on Add component i havent really found anything with color. So right now when i start up unity there comes up this box that has Video tutorials, and i click on it and theres only simple explanations of like every single thing unity, but not really for my problem, so It would be even more kind of you (Considering how you have helped me so far) to say Where is can find this Color component or a good one.
Dude you have to add a material. I canโt say it any simpler than that. Google it
Can you link a video about this? Because im still confused.