Laris Bania
First Post
I am facing an issue with customized walk code with will help the animation to have special moves. This is being set in the 3rd person controller of Unity3D. But it is not shown on the menu.
This simple animation task is fetched from FBX file with walk model structure. Still, I know about, how this animation is working and I can easily use it in the idle form. Controller script is working fine as I can use this prototype without any stringed values. From the code, it is clear that animation is the selected one from the anime component (this is the automatic play option) I am unable to change anything from the 3rd person controller. If I use the prototype character, it is working fine, but for me, nothing is working.
I don't have nor want run and jump animations. Animation collection is simple with 0 run and jump shots. Executing walk animation with prototype has no effects, using simple controller commands. Controller does not have the control over the animations so that it could turn those off. As the controller is searching for 3rd person controller logs in the script. CrossFade is being called but with no reverse effect.
You can see the controller code. This is working fine with sample model as it is provided with Unity kit. I am using _animation.CrossFade, but using play is not providing any help. I can't see any logs in console. With custom anime, the whole setup does not work (even the slightest movement failed)
I am thinking about the issue with the model; I am using. But, I can't share the code (sorry) due to company policy. I already contacted the animator to know more about FBX export. What are the specific settings, he had to configure to work with Unity fully? It remains odd though that the animations do work if I add them independently to the scene. Remember, that animations are working in the desired way, I addition is independent to the scene I am using.
Update 2: Current are the settings, I am trying to configure.


This code has a particular usage. From the code, it is clear that I don't want the backward or slow movement. Also, only the rapid forward movement is the focus throughout the implementation of the code. This is due to the fact this animated code will not be part of a computer game but real time tracking. Drones will fetch the data in a raw form to a processing device; this processing device will transfer the data to a big computer which will take the input as variables and transform this into proper animations. This application will be used by CoastGuards, as it will allow tracking of illegal movements without any active personnel on the ground. Current testing is performed at http://militarybases.co/directory/aviation-training-center-coast-guard-base-in-mobile-al-2/ with hundred of people moving in the field. Also, you can see, if the movement is backward or slow (this means that there is no danger), also, you can now know about the importance of 3rd person control (as discussed above). Also, some simple machine Artifical Algorithms will be used too, these algorithms will be fed with the live feed too to make decisions. If fully implemented, there will be the significant reduction of mobile coastguard patrol on the ground.
This simple animation task is fetched from FBX file with walk model structure. Still, I know about, how this animation is working and I can easily use it in the idle form. Controller script is working fine as I can use this prototype without any stringed values. From the code, it is clear that animation is the selected one from the anime component (this is the automatic play option) I am unable to change anything from the 3rd person controller. If I use the prototype character, it is working fine, but for me, nothing is working.
I don't have nor want run and jump animations. Animation collection is simple with 0 run and jump shots. Executing walk animation with prototype has no effects, using simple controller commands. Controller does not have the control over the animations so that it could turn those off. As the controller is searching for 3rd person controller logs in the script. CrossFade is being called but with no reverse effect.
You can see the controller code. This is working fine with sample model as it is provided with Unity kit. I am using _animation.CrossFade, but using play is not providing any help. I can't see any logs in console. With custom anime, the whole setup does not work (even the slightest movement failed)
I am thinking about the issue with the model; I am using. But, I can't share the code (sorry) due to company policy. I already contacted the animator to know more about FBX export. What are the specific settings, he had to configure to work with Unity fully? It remains odd though that the animations do work if I add them independently to the scene. Remember, that animations are working in the desired way, I addition is independent to the scene I am using.
Code:
// Same character is required for each object
@script RequireComponent(CharacterController)
public var idlemovement : AnimationClip;
public var walkscene : AnimationClip;
public var maxmovspeed : float = 0.83;
private var _custommovanim : Animation;
enum CstateChar {
Idle = 0.1,
Walking = 1.1,
}
private var _CstateChar : CstateChar;
// Variables of simple walk
var wspeedsimple = 1.7;
var wspeedS = 9.8;
var rotationS = 437;
var targetPro = 5;
var destinationDistance = 200;
// Difference between recording and movement of the object
private var lCT = 0.3;
// Current XZ dimention movement
private var simpleMov = Vector3.zero;
// Speed in horizontal axis
private var moveSpeed = 0.0;
// Last value controller
private var CollideIndicator : CollideIndicator;
// Backward mpvement as camera can't easily detect it
private var simpleB = false;
// Initialzing the key movements
private var littleisMove = false;
private var trueControll = true;
private var isTargetting : boolean = false;
private var targetPoint : Vector3 = Vector3.zero;
function Awake () {
simpleMov = transform.TransformDirection(Vector3.forward);
_custommovanim = GetComponent(Animation);
if(!_custommovanim)
Debug.Log("No animations for this character. Doing so, is not the suitable movement");
if(!idlemovement) {
_custommovanim = null;
Debug.Log("Can't see the pefect idle animes. It is recommended to turn off the animatsion");
}
_custommovanim[idlemovement.name] = idlemovement;
if(!walkscene) {
_custommovanim = null;
Debug.Log("0 walking. It is good, if you could turn off those animations");
}
_custommovanim[walkscene.name] = walkscene;
}
function UpdateSmoothedMovementDirection () {
var cameraTransform = Camera.main.transform;
// Relative camera movement
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
// Relative camera xz moveemnt
// Getting orthogonal vector
var right = Vector3(forward.z, 0, -forward.x);
var v = Input.GetAxisRaw("Vertical");
var h = Input.GetAxisRaw("Horizontal");
// Getting backward movements of the scene
if (v < -0.2)
simpleB = true;
else
simpleB = false;
var wasMoving = littleisMove;
littleisMove = Mathf.Abs (h) > 0.1 || Mathf.Abs (v) > 0.1;
// Getting the relative direction from the user
var targetDirection = h * right + v * forward;
// Using the lock time for small glitches
lCT += Time.deltaTime;
if (littleisMove != wasMoving)
lCT = 0.0;
// Using different variables for speed and distance
// To get the real work of the standing character in the valid direction
// Getting normalization factor invovled in the small time
if (targetDirection != Vector3.zero) {
// Snapping the slow movement
if (moveSpeed < wspeedsimple * 0.9) {
simpleMov = targetDirection.normalized;
}
// In opposite case, smooth turn
else {
simpleMov = Vector3.RotateTowards(simpleMov, targetDirection, rotationS * Mathf.Deg2Rad * Time.deltaTime, 1000);
simpleMov = simpleMov.normalized;
}
}
// Current targest Smoothness
var curSmooth = wspeedS * Time.deltaTime;
// Carefully choosing the target in terms of speed
//* Small analog movements and carefully mentoring horizontal cases
var targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0);
_CstateChar = CstateChar.Idle;
// Configuring the speed modifier
targetSpeed *= wspeedsimple;
_CstateChar = CstateChar.Walking;
moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth);
}
// Smooth the speed based on the current target direction
var curSmooth = wspeedS * Time.deltaTime;
// Choose target speed
//* We want to support analog input but make sure you cant walk faster diagonally than just forward or sideways
var targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0);
_CstateChar = CstateChar.Idle;
// Pick speed modifier
targetSpeed *= wspeedsimple;
_CstateChar = CstateChar.Walking;
moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth);
}
function Update() {
if (!trueControll) {
// kill all inputs if not controllable.
Input.ResetInputAxes();
}
var distance : float = 0;
if (Input.GetMouseButtonUp(0)) {
if (isTargetting) {
isTargetting = false;
// Debug.Log("Stopped moving");
FaceCamera();
} else {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var layerMask = 1 << 8; // Terrain is layer 8
var hit : RaycastHit;
Physics.Raycast(Camera.main.transform.position, ray.direction, hit, 1000, layerMask);
distance = Vector3.Distance(transform.position, hit.point);
if (distance <= destinationDistance && hit.point != Vector3.zero) {
targetPoint = hit.point;
isTargetting = true;
// Debug.Log("Mouse up at hit " + hit.point + " at distance " + distance);
} else {
isTargetting = false;
// Debug.Log("Ignored mouse up at hit " + hit.point + " at distance " + distance);
}
}
}
if (isTargetting) {
// Debug.Log("Moving to " + targetPoint);
distance = Vector3.Distance(transform.position, targetPoint);
if (distance < targetPro) {
// Debug.Log("Reached point " + targetPoint + " at distance " + distance);
isTargetting = false;
FaceCamera();
} else {
UpdateTargettedMovementDirection();
}
} else {
UpdateSmoothedMovementDirection();
}
// Calculate actual motion
var movement = simpleMov * moveSpeed;
movement *= Time.deltaTime;
// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
CollideIndicator = controller.Move(movement);
// ANIMATION sector
if (_custommovanim) {
if (controller.velocity.sqrMagnitude < 0.1) {
_custommovanim.CrossFade(idlemovement.name);
} else {
//_custommovanim[walkscene.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, maxmovspeed);
_custommovanim.CrossFade(walkscene.name);
}
} else {
Debug.Log("Animation is null!");
}
// ANIMATION sector
// Set rotation to the move direction
transform.rotation = Quaternion.LookRotation(simpleMov);
}
//Getters and setters for the whole scene
function FaceCamera() {
var cameraTransform = Camera.main.transform;
// XZ vector with relative forward movement
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
simpleMov = -forward;
}


This code has a particular usage. From the code, it is clear that I don't want the backward or slow movement. Also, only the rapid forward movement is the focus throughout the implementation of the code. This is due to the fact this animated code will not be part of a computer game but real time tracking. Drones will fetch the data in a raw form to a processing device; this processing device will transfer the data to a big computer which will take the input as variables and transform this into proper animations. This application will be used by CoastGuards, as it will allow tracking of illegal movements without any active personnel on the ground. Current testing is performed at http://militarybases.co/directory/aviation-training-center-coast-guard-base-in-mobile-al-2/ with hundred of people moving in the field. Also, you can see, if the movement is backward or slow (this means that there is no danger), also, you can now know about the importance of 3rd person control (as discussed above). Also, some simple machine Artifical Algorithms will be used too, these algorithms will be fed with the live feed too to make decisions. If fully implemented, there will be the significant reduction of mobile coastguard patrol on the ground.