Setting Camera Between two objects

Get help using Construct 2

Post » Mon Jan 30, 2012 5:16 am

Hey Forum Friends! Could you help me figure this out?

I have two objects moving on the screen. I have a camera sprite that I want to position between the two sprites regardless of where the two sprites move. Theoretically, I want to zoom in and out depending on the distance between the two sprites. (I think I can figure that out, but the positioning of the camera is what I am stuck on.)

I am guessing I will need a variable MidPoint with Distance(Sprite1.x, Sprite1.y, Sprite2.x, sprite2.y) / 2. But now how to I get the X and y? Using sin and cos? I am lost...

Thanks in advance!
Posts: 213
Reputation: 10,178

Post » Mon Jan 30, 2012 6:32 am

Object1.X + (object2.X - Object1.X) * 0.5
Object1.Y + (object2.Y - Object1.Y) * 0.5

Here's an old cap I did with everything stripped away apart from this feature..

object 2 is the mouse.
Changing '0.5' to a variable means you can adjust the distance.. so holding down space changes the number to 0.5 from 0.3
Oh and If you want a smoother scrolling, make a separate marker object and have it move at angle.. with the speed in accordance to the distance between itself and the position written above.

I did do one for magnification also but I can't find it..
But I do remember it was a bit of a pain to do mouselook with magnification, because zooming out would cause the mouse to be recognised even further away and it got really sensitive the further the mouse got.
Posts: 469
Reputation: 4,683

Return to How do I....?

Who is online

Users browsing this forum: AwesomePuppy, erickson400, miketolsa, RoboFrosty and 8 guests