Forum rules - please read before posting.

Snap draggable to postion along track on input release

Sorry if this is answered elsewhere, I've been trying to search for a while but can't seem to find it.

What I would like to do is have a draggable object that interacts normally while the user is dragging it but when they release the mouse button (or other input method) a script 'snaps' the location along the track to either 0 or 1. I suppose there might be future cases where I would like it snapped to other locations like halfway or something but for now I'm just trying to have a knob that can be slide to 'on/off' but still has the 'feel' associated with dragging.

I've tried writing a script that executes on moving the draggable and checks the InteractionA input and if 'not met' it checks the location along the track and sets the location based on whether it is halfway or not and if 'met' just loops back but this doesn't seem to work. It just makes the dragging really jerky and it doesn't seem to properly detect the user's state.

Thanks for any ideas!

Comments

  • Ok, I tried another way of doing this. I wrote a new ActionList for the Draggable 'Interaction on move:' in which I check if the draggable object is being held by the player and if not I try to update the position. This has the problem that if I stop moving the object before letting go then the 'on move' isn't triggered and the script doesn't work. So I added behavior for if the object was being held to call the actionlist again (loop back on itself, picture below) and this fails now because for some reason doing this puts the game into a 'Cutscene' state which makes it so I stop dragging which makes it so that the 'snapping' happens almost instantly after I start dragging. Is there a proper way to do this?

    Thanks.

    image
  • Just in case anyone else searches and finds this post I was able to resolve the problem by making this interaction (actionlist) run in the background which is an option in the Inspector page that isn't in the ActionList Editor. I then created a helper interaction that stops the above pictured interaction from running and starts it again every time a move happens and the in-game behavior is as desired.
  • thanks man that was very helpful
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.