Camera Tracking two characters for fight game

Guys help me iam creating a fight game like mortal kombat or those we create in mugen
but dont know how to track both characters. the game is in 2d fashion. thus far i have used only logic bricks but python script will also do the job. thanks in advance

Attachments


you have to do this:

Make an empty to stay just in the center of fighters (python)
Make a camara track this empty
Make an ipo for the camera, from near to far to this emtpy.
And make a script form make the camera to get the right position to get both fighter fit in the scene.

I have and old example somewhere, I’ll try to find it.

thanks for the reply ,i thought of something similar to it, but not able to execute it

i found these files but those dont work with version 2.61 as iam new to blender iam not able to make them work for my 2.61 version can you help :eek:

Where did you get them from?
If it is not your work then show your sources ;).

Just a hack to upgrade to 2.49+ API
co-opCamRot.blend/AveragePoint.py


import GameLogic


c = GameLogic.getCurrentController()
zoomControl = c.owner
scene = GameLogic.getCurrentScene()
players = []
points = []
totalP = [0.0, 0.0, 0.0]
averageP = [0.0, 0.0, 0.0]
largestDistance = 0
scaling = 0.15
reset = 30

for i in range(1, (zoomControl["players"] + 1)):
		players.append(scene.objects['Player' + str(i)])
	#this allows as many players as you like, they just need to have an object near them, or even themselves, to have the name "Player#", where # is a number between 1  and the value of the zoomControl object's "players" attribute.

if len(players) > 1:
	for i in range(0, len(players)):
		points.append(players[i].worldPosition)		
		for x in range(i, len(players)):
			dist = players[i].getDistanceTo(players[x])
			if dist > largestDistance:
				largestDistance = dist
		
else:
	largestDistance = reset
	points.append(players[i].getPosition())	
	
if len(points) > 1:	
	for i in range(0, len(points)):
		currentPoint = points[i]
		totalP[0] = totalP[0] + currentPoint[0]
		totalP[1] = totalP[1] + currentPoint[1]
		totalP[2] = totalP[2] + currentPoint[2]
		
	averageP[0] = totalP[0] / zoomControl["players"]
	averageP[1] = totalP[1] / zoomControl["players"]
	averageP[2] = totalP[2] / zoomControl["players"]

else:
	averageP = points[i]
	

zoomControl.worldPosition = averageP
zoomControl["zoom"] = int(largestDistance * 2)

it is not the best designed code, but it seems to work

thanks i will try that but wanna know are those codes are yours if yes ,sorry dont exactly rememberd the sources i will definately credit you for these

it doesnt seem to work can you send a blend file for 2.6+ please…i will be very greatfull if u do thanks in advance

This is not my code, no need to credit me :eyebrowlift:.

Attachments

co-opCam_revised.blend (219 KB)co-opCamRot_revised.blend (228 KB)

thanks a lot it will work for me…

Hello im doing by myself almost the same thing, before discover this post, but learn a lot in the way. :yes:

i have a question, when happen a sudden change of a player position, the jitter of the camera are uggly problem, im testing the main problem is the sharp camera movement . Any idea how to fix that ?, i have nothing in mind. Ill keep trying