3 N00B Questions

Hi I’m new and a total N00B. I was wondering if any of you wonderful people can help me out and answer a few of my questions:

  1. Are there any tutorial out there that teaches you how to create a game in which the user could control an animated character in third person?

  2. Is there a way, when I make a script for the user to enter a new level, to keep all the things the player had done. Like for example: If the player lost 10 health on level 1, how could I make it so that when they enter level 2, they have 90 health? Or, the same amount of health/ammo/ect. they had last level?

  3. Also, this question is a bit difficult to understand. When a player enters level 2 from level 1, how could I make them appear somewhere else on the map (Not the place the camera starts) when they go back to level 1?

I hope one of you helpful users could help me with these questions. I would be very grateful.

Thanks.

1.) Check out this 3rd Person demo: http://unity3d.com/examples/ThirdPerson.zip

2.) You can use this to keep an object alive over the span of a different levels: http://unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

3.) Not sure what you mean exactly :confused:

The answer to this is the same as for #2 (no wonder they were both labelled #2 8) ). Basically, you want a script attached to the player that sets their starting point based on information from an object you’ve saved from the previous level using DontDestroyOnLoad.

Thanks guys. You made it sound so easy. Now I feel stupid!

Sorry if my post was a little confusing (Especially since I labeled two of my questions number 2 :/)

Thanks for the quick reply guys.

Thank you for your answer, but do you know of any way of making a third person game in which the camera is behind the character all the time?

Thanks.

I believe this does that (taken from the ScriptExamples project)

var target : Transform;
var distance = 5.0;
var xSensitivity = 5.0;
var ySensitivity = 5.0;
var xAngle = 0.0;
var yAngle = 0.0;

function LateUpdate ()
{
	// Only if there is a target
	if (target)
	{
		// Update x, y angle with the mouse delta
		xAngle += Input.GetAxis ("Mouse X") * xSensitivity;
		yAngle -= Input.GetAxis ("Mouse Y") * ySensitivity;

		// Initialize the position to be distance units along the z axis
		// away from the target
		transform.position = Vector3.fwd * distance + target.position;

		// Initialize the rotation to look at the target
		transform.LookAt (target.position);
		
		// Rotate around the world up axis by the accumulated delta mouse x
		transform.RotateAround (target.position, Vector3.up, xAngle);

		// Rotate around our own right vector by the accumulated delta mouse y
		worldRight = transform.TransformDirection (Vector3.right);
		transform.RotateAround (target.position, worldRight, yAngle);
	}
}

Thanks for the quick reply.

I’ll try that piece of code, thanks.

Provided your character follows the z axis, theres another way. Attatch the smooth follow script to a camera by selecting camera then going component> camera control> smooth follow, then assigning the character to the empty slot in the inspector where you see the smooth follow script.

You may want to assign the characters head instead, so long as it points along the z axis also. You can create an empty game object and parent it to your character to create a node in the right location and rotation if you so desire too.

Quick and easy…
AC

If you want to lock the camera in place, you can just make it a child of the thing you want it to follow. No scripts necessary.