How to Constrain To Mouse With An Offset Camera?
Hey guys, I'm using TSB's ConstrainToMouse template found here: http://gshelper.com/?p=377 for picking up and dropping objects. It's awesome except that it doesnt work if my camera origin is elsewhere. (My scene is 30,000px wide) How can i adjust it so it will work if the camera origin is not at it's default?
I'm guessing I'd have to do something at the scene/instance level since you can only do camera/constraining at the scene level.
Any hint would be much appreciated!
cheers.
I'm guessing I'd have to do something at the scene/instance level since you can only do camera/constraining at the scene level.
Any hint would be much appreciated!
cheers.
Comments
For my Game, Penguin Pounce, I needed to change the X position of my camera origin to 477.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
You'll need to unlock the instance to get at the camera settings
http://www.funkymunkygames.com/promo/constraintomouse_bigscreen.gameproj.zip
Note: in the scene actor (bomb) I had to add camera.origin.X and Y twice (once in this rule: 'when touch is pressed grabbed to true' and the second in the constrain rules). I also added a camera control.
Also there were some invisible walls in there that blocked movement so I have removed them but you may want to wall in the outside of the scene so the bomb doesn't travel out of sight.
so for example if the game.mouse.position.X is in an equation you will need to add the camera origin with parentheses:
(game.mouse.position.X+current.scene.camera.origin.X)
maybe that's the problem
When mouse button is down
self.touchdistance > magnitude( self.Position.X - game.Mouse.Position.X + scene.Camera.Origin.X , self.Position.Y - game.Mouse.Position.Y + scene.Camera.Origin.Y )
change self.grabbed = true
When self.grabbed is True
self.motion.linear velocityX to: 20*( game.Mouse.Position.X + scene.Camera.Origin.X - self.Position.X )
self.motion.linear velocityY to: 20*( game.Mouse.Position.Y + scene.Camera.Origin.Y - self.Position.Y )