How do I set CameraSprite between player & mouse position

Get help using Construct 2

Post » Fri Jul 10, 2015 3:21 am

How do I set my Camera Sprite between Player Sprite and Mouse Position?
Image
in a similar fashion to how nuclear throne does it - most likely using minimum &max values to stop the camera moving any further.
B
29
S
6
G
2
Posts: 232
Reputation: 2,893

Post » Fri Jul 10, 2015 4:24 am

Just set your camera's position to the average position between your player and the mouse. Something like:

X = (Player.X + Mouse.X) / 2
Y = (Player.Y + Mouse.Y) / 2

If you want to get fancy and control where in between the two your camera lies, you can use lerp:

X = lerp(Player.X, Mouse.X, 0.25)
Y = lerp(Player.Y, Mouse.Y, 0.25)

This specific example would place the camera 25 percent of the way from the player to the mouse.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Fri Jul 10, 2015 5:22 am

thanks @linkman2004 luckily I was able to resolve my little problem. This was the end result I got and was going for.
Image
I did it by doing this. made it changeable for any later uses . no performance hit after few seconds after start of the layout -
Image
used windows snipping tool on windows 8.1 to get the custom screenshot
B
29
S
6
G
2
Posts: 232
Reputation: 2,893

Post » Fri Jul 10, 2015 4:16 pm

I wouldn't recommend using dt in a lerp function like that, as it's likely not doing what you think it is. If your FPS -- and by association, the value of dt -- starts to fluctuate, you'll find your camera jumping around. If you want smooth camera movement with dt, you should be lerping the camera position toward a fixed point between the player and mouse.

Alternatively, you could look at my Magicam plugin, which does motion smoothing and multi-object following.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Fri Jul 10, 2015 4:49 pm

@linkman2004 Understood. I'm quite use to using it in other engines with games running at frame rate ranging from 30 -1000+ FPS. made the lerp speed more quickly understood by any group members.

trying to not use any third party plugins as much as I can but thanks.
B
29
S
6
G
2
Posts: 232
Reputation: 2,893


Return to How do I....?

Who is online

Users browsing this forum: fearfulelephants and 21 guests