Комментарии:
Thanks
ОтветитьCan this method be used universally with if statements for doing stuff click on any object w ith a rigidbody or only the objects this script is attached to? What a stupidly short tutorial short tutorials like these waste more of peoples time trying to figure stuff out than it saves
Ответитьi think the problem with the tutorial is that you use things outsikde the tutorial sobject or in other words insert something thaty is not teached from the subject you are talking about so yeah i hbope you make a new tutorial series but actually helpful
ОтветитьThese videos never seem to spell out all that is actually required for their functionality to work. Here, the GameObject clicked on needs to have a collider whose isTrigger=true, Physics.queriesHitTriggers must be set to true, and the item clicked on needs a RigidBody. Also, this seems like a missed opportunity to discuss questions of what happens if multiple items are under the mouse, how to precude "clicking through walls", etc
ОтветитьWhy it is not inside the update()?
ОтветитьDoesn't work on 2d, does it only work on 3d collieers
ОтветитьIs there a way of setting a maximum distance from the object when clicking? For example using an FPS controller, you could use this script to open a door, but without a range check you'd be able to open the door from far away.
Any help appreciated.
I have a question: there is any function that detects if the click of the mouse occurs outside of the object?
ОтветитьI've been using Unity for 2 years and never new about OnMouseDown, OnMouseEnter, OnMouseExit as special functions. I was always using some kind of Camera Raycast through mouse to hit colliders to run any functionality, but this is 100x easier! If anyone wants to test it out, you can use the following code as a component of a 3D collider (like a default cube or sphere) and play with it in a new unity project:
public class MouseAction : UnityEngine.MonoBehaviour
{
void OnMouseDown()
{
transform.position += UnityEngine.Vector3.right;
}
void OnMouseExit()
{
transform.localScale *= 0.5f;
}
void OnMouseEnter()
{
transform.localScale *= 2;
}
}
its been years since I've looked at anything programming but here I am at 5:30 am lol
ОтветитьWhat is the diffrence between OnMouseDown and Raycasting from screen click position? Perfomance?
ОтветитьNice when I get my new laptop Amma try these stuffs
ОтветитьIs der also a more aesy way to make phone games
ОтветитьPlease what is the difference between transform.forward and Vector3.forward?
Ответить