Forum rules - please read before posting.

Attaching objects to mouse

edited January 2017 in Technical Q&A
Hey all - 

I'm playing around with physics objects but I'm not getting the behavior that I'm needing.  For a puzzle that I'm working on, I am in a close-up interaction mode with three objects and a fourth object that is being interacted with (constructing something).  What I'm wanting to do is click on the object and have it lock to the mouse cursor, then be able to mouse over to the object that's being interacted with and click again (basically have a hotspot on hotspot interaction).  I've been trying to do this with the moveable/physics objects but I don't want to give the player full freedom with the object, so if they accidentally drop it it could go outside of the camera's view (or someone could accidentally toss it off frame)...plus, I'd rather not have it be a pick up/drop on an object interaction.  I want it to be click to pick up and then click to attach to another object.

Is there a way to get my desired behavior out of the moveable/physics objects or with some other actionlist method out of box or is this going to require some unique code?

Comments

  • If you don't want to rely on PickUp objects, it'll certainly require custom code.  If you're using the mouse for your game's input, you can simply read Unity's Input.mousePosition to get the mouse position.  More tricky is to convert it into 3D space.

    What AC can offer is an example on how to do that: the World Space Cursor Example.  Test it out by attaching it to a 3D object (no collider) - it'll take the position of the mouse.  The code is commented, so you can copy and adapt to suit your needs.
  • Awesome!  Thanks, Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.