- Home /
Lerpz Animation, Not Connected??
I Set the Third Person Player Animation (Script) to The Player Tab and when i click the "play" button, the screen zooms onto Lerpz but i can't control him, just the camera of the screen
This is the error message that comes up:
MissingComponentException: There is no 'Animation' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Animation to the game object "Player". Or your script needs to check if the component is attached before using it. ThirdPersonPlayerAnimation.Update () (at Assets/Scripts/Player/ThirdPersonPlayerAnimation.js:69)
I checked line 69 of the script but all it showed was a { . Could anyone tell me how to fix this?
Answer by iDesign · Aug 21, 2012 at 08:02 PM
-Help was very appreciated Charles-
I dragged the Lerpz prefab to the Hierarchy
I downloaded the Lerpz prefab from the Unity Sites Tutorial
When i play the game the Camera Zooms in from far onto Lerpz then instead of controlling Lerpz himself, i control the camera. The capsule collider is well placed at 1.03 "y" around Lerpz.
Here is the Script at 69:
{ ApplyPositionDamping (Vector3(targetCenter.x, targetHeight, targetCenter.z)); } SetUpRotation(targetCenter, targetHead); } function ApplySnapping (targetCenter : Vector3) { var position = transform.position; var offset = position - targetCenter; offset.y = 0; var currentDistance = offset.magnitude; var targetAngle = target.eulerAngles.y; var currentAngle = transform.eulerAngles.y; currentAngle = Mathf.SmoothDampAngle(currentAngle, targetAngle, velocity.x, snapLag); currentDistance = Mathf.SmoothDamp(currentDistance, distance, velocity.z, snapLag); var newPosition = targetCenter; newPosition += Quaternion.Euler(0, currentAngle, 0) * Vector3.back * currentDistance; newPosition.y = Mathf.SmoothDamp (position.y, targetCenter.y + height, velocity.y, smoothLag, maxSpeed); newPosition = AdjustLineOfSight(newPosition, targetCenter); transform.position = newPosition; // We are close to the target, so we can stop snapping now! if (AngleDistance (currentAngle, targetAngle) < 3.0) { isSnapping = false; velocity = Vector3.zero; } }
Do you think there might be a problem with the target height? Anyway i hope this helps
Hmmm... Very Strange, I would first check to ensure you placed the components on their correct gameObjects. Usually when one object behaves the way another should it means a script was accidentally placed on the wrong gameObject or that the wrong parameter was given to a script. For instance a script may require the transform of the player, but any Transform can be dragged into the script. So my second suggestion would be to check if the tutorial asked you to drag an object from the hierarchy to a place on a script that you dragged the right object to the right place. At the moment it sounds like the script for controlling the player is somehow manipulating the camera transform rather than the player's so either the script that handles player motion is on the wrong object or was given the transform. Honestly, I would like to give you a definitive answer but there really are a million different reasons as to whats wrong. If my suggestion doesn't yield better results try finding a download for the completed Lerpz project and cross check it to the letter with your own, that will give you your answer but will of course take time.
Answer by CharlesD · Aug 21, 2012 at 07:03 AM
Ah I wish someone would update that tutorial, some parts of it just seem out of date nowadays. But anyways... the error you received was not necessarily because of your script, while it did encounter an error it was not because it wasn't functioning correctly but rather it was looking for something that did not exist (See Dependencies in the blue box on page 16 of the tutorial). The ThirdPersonAnimation component depends on a component of type Animation to work and according to the error you received, there is no Animation component on the player. Now I believe that the Lerpz prefab you should have drug into your level at the start of the tutorial has an Animation component already attached to it, if not then the ThirdPersonAnimation component you added should have added one for you or there is something wrong with the assets you downloaded for the tutorial. I can't really answer in detail what's wrong without knowing a few more details however. First, did you in fact drag the Lerpz prefab from the project window into your scene? Second, did you download the Lerpz tutorial from Unity's website or somewhere else? Finally, does your Player have an animation component attached (click your player in the Hierarchy view then look for it in the inspector)? Oh and one final side note, you are probably wondering why the error message you received was pointing to a specific line in a specific script... well whenever a script encounters a problem an error is logged with unity, the line # is simply an indication to the specific part of the code which encountered a problem, be it a problem in the script such as syntax or a problem the script encountered. In your case the error points to a specific block of code where the script encountered a problem starting at line 69 and ending somewhere else the "{" and its partner "}" indicate a block of code. Sorry if what I said seems either too complicated or too basic, I'm trying to give you all the information I can.
Answer by capasha · Feb 26, 2013 at 01:42 AM
I had the exactly same issue. I recreated everything and followed the tutorial again. And found in one of the images did it exists Animation in the Inspector for the Player object. Which I didn't have in my Inspector. So I just added a Animation from Add Component. But still got a lot of errors. I Clicked on the circle between walk, and clicked on all animations. And tried to run. Now didn't I get any more errors. But I still can't control the player. Which is there I'm stuck now.
^ Used wrong method.
Edit: Looks like I have been changing the Child instead of the Root Object.
Your answer
Follow this Question
Related Questions
Lerpz Tutorials Animation Problem 0 Answers
blender animations problem (or bug) in mecanim 0 Answers
UCE0001: ';' expected. Insert a semicolon at the end 1 Answer
Animation problem 1 Answer
Rotation in animation problem 0 Answers