Shoot to X,Y problems
forklift
Member Posts: 386
Admittedly, I started the game prototype in iphone landscape, but switched to ipad landscape... maybe that's the problem. However, I have an actor shooting to x,y in the following manner.
screen W 2048 x H 768
camera W 1024 x H 768
When mouse is pressed
- spawn 'bullet' actor
--vector to angle (game.mouse.x - self.position.x, game.mouse.y - self.position.y)
And this works - partially. It will fire where i press the mouse button until the actor moves to what feels like outside of a 1024 W box from the start location, then the mouse firing x,y tracking gets completely off. But when i move the actor back inside that magic area, it tracks fine.
Think I can be missing something?
screen W 2048 x H 768
camera W 1024 x H 768
When mouse is pressed
- spawn 'bullet' actor
--vector to angle (game.mouse.x - self.position.x, game.mouse.y - self.position.y)
And this works - partially. It will fire where i press the mouse button until the actor moves to what feels like outside of a 1024 W box from the start location, then the mouse firing x,y tracking gets completely off. But when i move the actor back inside that magic area, it tracks fine.
Think I can be missing something?
Comments
*EDIT* That link looks like it will fix the problem. Thanks for the heads up! I'll be back if problems persist. As always, this forum is really what makes GS awesome.
I've constrained a global camera attribute to a prototype like so:
Constrain Attribute: game.CameraX To: Scene.Camera.Origin.X
Constrain Attribute: game.CameraY To: Scene.Camera.Origin.Y
But it doesn't work as written below:
When mouse is pressed
- spawn 'bullet' actor
--vector to angle (game.mouse.x - self.position.x + game.CameraX, game.mouse.y - self.position.y + game.CameraY)
I've tried a ton of variations (spent 3 hours on it last night, 6 hours total), even constraining the (game.mousex - self.position.x) to calculate that by itself and add game.cameraX in the vector to angle, but still nothing. I feel like I'm way off... insight?
vectorToAngle( game.Mouse.Position.X + game.CameraX - self.Position.X , game.Mouse.Position.Y + game.CameraY - self.Position.Y )
Also relative to actor.
See/download the example project. http://gamesalad.com/game/play/85077
I noticed you changed the place of '+ camera' relative to the 'mouse position'. I will try your way and thanks for the demo!
Mine:
vector to angle (game.mouse.x - self.position.x + game.CameraX, game.mouse.y - self.position.y + game.CameraY)
Yours:
vectorToAngle( game.Mouse.Position.X + game.CameraX - self.Position.X , game.Mouse.Position.Y + game.CameraY - self.Position.Y )
Will update if it worked or not.
But I am happy to report that after a total of close to 10 hours of different formulas, the problem is fixed. The logic: Does work. The problem was in something totally different and so dumb that I didn't feel the slightest bit of relief that the problem was fixed.
Let this be a lesson to all the new guys: The instance where the camera constraints were located was being affected by gravity... hence falling off my scene into limbo. So no wonder the camera coordinates weren't working. The dumb thing kept being destroyed off-screen.
Anyway, I made a ton of progress after that, so I've almost got a complete prototype. I should be finished with the rest of the prototyping by the end of this week. Thanks for all the pointers.