Hello, after one day of trying see why I cannot make respond my object to collision with the cursor input of britzl example, I realize that all is ok but just the cursor is x and y way down, and this happens because I use also the drag and scroll camera, so when I drag the camera to other place the cursor object is at other place from cursor. This I saw when I put a sprite and at start was with the cursor and after drag was not. So how can this solved ?
Well, the input your receive from Defold is in screen space, meaning that lower left corner of the screen is always [0,0] and the top right is [width,height].
Game object positions are on the other hand in world space. If you don’t use a camera the world space is the same as the screen space. A game object in the lower left corner is at [0,0] and a game object in the top right corner is at [width,height].
But what if you have a camera and move this in the world? In that case screen and world space coordinates will no longer match and you need to take the camera offset into account when you translate the screen space coordinate of the mouse/cursor into world space when you position the cursor object.
The Defold-Input repo also has an example showing how to deal with this “problem”: Defold-Input 0.1 (see camera+cursor example). This example uses the Defold-Orthographic camera extension which provides screen to world conversion.
thanks for the info, so put orthographic camera and translate in controller the world? yes? and in camera object of drag and scroll use again a this orthographic? by put render of it. thanks
I put the controller script of camera + cursor and I put orthographic. But when I made a camera object with camera orthographic and drag and scroll inside when I moved mouse went I very far. also how can I have the object of camera with same options like in drag example but with orthographic camera render?
thanks
britzl now with drag I went to x = 12000 out of map has bounds and follow target for example I can put follow cursor and set bounds but with follow cannot use the drag and scroll, orthographic destroys to me the previous function. Cannot make a camera object like you done at drag and scroll and set in the script of drag. The object of orthographic camera does not let you set inside a component. Or at least do not know how. thanks
what I manage is follow the cursor which is difficult I set bounds… but all I wanted was your example of drag and scroll to keep same functionality but not loose the cursor because of different x,y of world. I tried to do like you said but cannot make a camera like before like with drag. If I put this code that has the manual is a way call it, but also in bulltin cannot save the render script if I copy paste in main ? can do? also how use this function with drag? orthographic camera render made all a mess… thanks
sorry britzl but because I am beginner donot know how to do it usualy I try your examples for understand sth but from yesterday where I search forum cannot fix it. please can you describe it a bit more so can understand? I understand that needs to be done screen to world pos but with orthographic cannot control at all. thanks
before I had your camera of drag and scroll and down the script of drag and scroll now how can do this?