Hi,
I’m trying to make a script so that I can click on an object and drag it around the screen. I’m sure it’s fairly simple but I’m not having much luck.
Can someone help me?
Thanks,
Stuart
Hi,
I’m trying to make a script so that I can click on an object and drag it around the screen. I’m sure it’s fairly simple but I’m not having much luck.
Can someone help me?
Thanks,
Stuart
I have never done anything like it, but I would suggest checking if youre hitting stuff with Camera.ScreenPointToRay. If you hit a movable object, then affect the x and y of that transform with Input.mousePosition.
Maybe thats not the right way of going about it, but check it out and see if you can make any progress
The solution depends on whether or not you’re looking at repositioning a 2d object such as moving a gui element about, or dragging about a rigidbody in 3d space.
If it’s the first, than TheInformand is giving you the correct solution. If it’s the second, then there is a DragRigidbody script I believe is included in the standard assets. If not, then you can grab it from the 'Room of Shadows" example scene.
Wow! In the standard assets? What luck.
There is only one problem though, while I am dragging the object it doesn’t collide with other colliders? Do you know how to let it collide?
The DragRigidbody script actually works by attaching a spring to the rigidbody object and moving the other end of the spring around. That is to say that the rigidbody should have correct physics as a result. If the colliding objects are both mesh colliders, then at least one of them needs to have the convex option enabled, otherwise a collision won’t be registered.
O I C Thanks a lot
Hello fellow game-software-developers,
If I try the 'Room of Shadows" example scene online Discover the latest Unity demos and projects | Unity, then I can not drag the chairs and lights.
I tested on Internet Explorer and Google Chrome … then I took Safari(forWin) - and the Chairs and Lights are wide awake! Allright, Safari is the coolest, but I don’t want to have to tell the users to not-use IExplorer or Chrome. Right before I posted this, I tested for FireFox and that works fine as well. Still what to do about IE and Chrome?
:idea: With a local build for Web Player, IE and Chrome do work just as well as Safari and Firefox. Is there a specific trick to buildig for Web Player?
I am trying to get to the bottom of Unity3D web deployment and especially mouse and game console interaction turns out to be quite difficult (for me).
Is there anyone savvy on this? :?
:!: Found out that Unity Web Player has something to do with this:
http://www.ms-news.net/f1907/directinput-does-not-work-activex-controls-ie8-protectedmo-8053047.html
I’m hoping maybe version 3.0 might remedy this…