Page 1 of 1

Small but interesting "view" example

PostPosted: Thu Sep 09, 2010 2:06 pm
by Nanorobot
I don't know exactly, maybe somebody already uploaded something like this.

But here I want to show you interesting example of navigating "view" actor in game. View will be always between player and cursor. I think it can be useful for some kinds of TDS games.

How it works? It is simple mathematics, let me explain. We need to find coordinates of actor, that locating right between player and cursor.
First, we find a coordinates of vector "player-cursor" = cursor.x-player.x ( the same for .y). Then we need to find a vector for point between player and cursor. = (cursor.x-player.x)/2. And then we need to find coordinates of that point = ((cursor.x-player.x)/2 + player.x)

If you can't understand what I mean, just download example and see!

I hope it would be useful for somebody.

I would be glad to see some comments!

Enjoy!

Re: Small but interesting "view" example

PostPosted: Thu Sep 09, 2010 3:01 pm
by lcl
Nice job! :D
That's cool! :D

Re: Small but interesting "view" example

PostPosted: Fri Sep 10, 2010 12:17 am
by DilloDude
You could also just use
(cursor.x + player.x) / 2
or
(cursor.x + player.x) * .5
(using multiplication instead of division, as it's more efficient)

Re: Small but interesting "view" example

PostPosted: Fri Sep 10, 2010 3:02 pm
by savvy
OMFG, this is exactly what i was gonna have to make for the game im doing currently :o
ty

Re: Small but interesting "view" example

PostPosted: Fri Sep 10, 2010 7:00 pm
by Hblade
Amazing :D