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:
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?
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?
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.
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.
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);
}
}
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.