hi there im having a bit of a brain block atm. i want to be able to click an object and the window would slowly scroll to it not instant like scroll to behavior, but i cant work out a way without it colliding with my scrolling code
which is this https://www.scirra.com/tutorials/415/dr ... uch/page-3
please help
use lerp and remove scroll To behavior. Add 2 variable to register mouse click position like clickX & clickY.
Set scroll:
for x > lerp(scrollX, clickX, 0.1)
for y > lerp(scrollY, clickY, 0.1)
one way this can be done is to make an invisible object that the windows follows like cross-hairs in a FPS. then instead of scrolling you would have a the "cross-hairs" move to the object. I have done this in one of my WIPs and it works great.
I'm also looking into more formal ways.
use lerp and remove scroll To behavior. Add 2 variable to register mouse click position like clickX & clickY. Set scroll: for x > lerp(scrollX, clickX, 0.1) for y > lerp(scrollY, clickY, 0.1)
Well I guess I don't have to look for a formal way, thanks for sharing this.
thanks for the replies guys
http://imgur.com/a/rbUK2
heres a screenshot of the code, its not working, i can see why its not working but im not sure how to fix it in the way you said
darkrealos
the Every Tick sub event will only run on the tick when the mouse click event fires. You need to have it be a top level event. Set clickx and clicky to scrollx and scrolly at the start of layout so that it doesn't move the camera location until you click to make it move.
Develop games in your browser. Powerful, performant & highly capable.
im sorry im not really following, i understand the every tick event wont work, kinda new that before hand should of removed , but im not sure whot to do the every tick event without it colliding with the scroll event
p.s. i dont completely understand the scrolling mouse code which makes it harder for me
thanks for everyone replies and help. ive managed to work it out with what you all said
Mind sharing your solution?