The rigidbody.js built-in in unity 5 doesnt work for me. Im trying to drag and drop a rigidbody using mouse drag and drop. Any help will be appreciated.
Here is a link to get you started, haven't tested but it should work fine with an object that has an attached rigid body. Drag Object with mouse
Related
I want to make an Inventory System in Unity, so I tried to follow this tutorial, but the functions OnMouseEnter and OnMouseOver are not working.
I tried everything like 3d colliders with z-value of 100, with trigger and not trigger, and also I checked if the Physics.queriesHitTriggers is true, but nothing works. Do you have any easy tips?
Not with raycasting... I'm quite new and don't understand this.
Try adding a box collider or box collider 2d
Try adding an rigidbody besides the collider and you can do it kinematic
Try adding add a EventSystem if you are using canvas ui
And verify that it does not have an object like a canvas blocking the camera raycast.
good luck.
The GameObject you're trying to use mouse with, needs to have at least one component that is a rayccast target. an Image or SpriteRendrer should do it.
The thing I found out is that OnMouseOver only works in the Game tab and not working in the Scene tab :)
It's much easier and cleaner to use Unity UI System to make Inventory, Just Create Canvas, Image inside of it and add EventTrigger component to that Image object, and modify events inside of it in the inspector, add any functions you want on any event it supports it, it is much cleaner solution. Try this tutorial https://www.youtube.com/watch?v=HZpq46W4xo4
U can do whatever you want with this system, just a little bit of thinking and planing your own Inventory Req...
Best of luck!
I have a eventsystem with 2 inputmodules (gaze (for cardboard) and touch). The gazeinput is above de touchinput, so that is going to be used by unity as main inputmodule. Now i have 1 object that i want to trigger on touchinput, but that is not working because of the gazeinput. So my question is if it is possible to disable the gazeinput just for this 1 gameobject?
EDIT: the object is a menu button, located in the bottom-right corner. It moves with the camera.
thanks
use raycast. when your camera is seeing the gameobject on which you want to use the touch input. detect that the user is looking at the camera via raycast.
Attach a script (to the camera or an empty gameobject) that has the reference of both the input modules
When the player looks at the object(detected through raycast) in which you want to use the touch input. Simply disable the gazeinput.
And when the player looks away from that gameObject enable the gazeinput
I'm doing a Standalone Windows 7 unity3d application for use on a multitouch IR Frame.
I usually use TouchScript and no problem with this. But now I don't know how to solve a new problem.
I have a texture with a uWebKit web and I need to send to this GameObject the touch drag to move a map and make zoom.
I can send touch Down and Up but I don't know how to pass the move.
It's ok for me to use other solution than TouchScript if go well.
Thanks you.
I'm new to Unity and using 4.6 version.
I have a prefab which is just a sprite. And I instantiate three of them.
I want to receive touch and mouse events from those instances.
So, I added EventTrigger component to them from c# script, and added ClickEvent.
And I also added IPointerClickHandler and implement of it.
But it never gets any event. What am I missing?
Is TriggerSystem only works with UI system? Because I did not add any UI Pannel or UICanvas or etc. ( instead I added an empty object and added TriggerSystem component to it )
If this is not a good way to do, please give me a direction to start.
Thanks in advance.
Below is for Mobile devices.
If you want to do in game controls without UI you can use Input
This is Unity document.
It pointed TouchPhase and all of touch phases can find here.
Unity document has good example codes i think you should check it.
For GUI system to work there should also be an EventSystem object in your scene.
You can do it the easy way too, from the editor add a collider2d to the the sprite.
Write this to an script attach it the the gameObject.
void OnMouseDown() {
// do something
}
Unity also convert mouse event to touch events on touch systems so you may not need to worry about simple touch events.
Guys
i want to drag a box2d object from touch move method in iphone
i have used the mouse joint but it is not working perfectly as object fluctuating within it's place like it is tied up with rubber
help is appreciated
thank you very much
The mouse joint is essentially a rubber band.
Destroy the body temporarily while dragging and re-create it again in -(void)onTouchEnded.