Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Community
General Tabletop Discussion
*Geek Talk & Media
Unity problems with 3rd person ground control
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Laris Bania" data-source="post: 6937674" data-attributes="member: 6863508"><p>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.</p><p></p><p>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.</p><p></p><p>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.</p><p></p><p>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)</p><p></p><p>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.</p><p></p><p></p><p>[CODE]// Same character is required for each object </p><p>@script RequireComponent(CharacterController)</p><p></p><p></p><p>public var idlemovement : AnimationClip;</p><p>public var walkscene : AnimationClip;</p><p></p><p></p><p>public var maxmovspeed : float = 0.83;</p><p></p><p></p><p>private var _custommovanim : Animation;</p><p></p><p></p><p>enum CstateChar {</p><p> Idle = 0.1,</p><p> Walking = 1.1,</p><p>}</p><p></p><p></p><p>private var _CstateChar : CstateChar;</p><p></p><p></p><p>// Variables of simple walk</p><p>var wspeedsimple = 1.7;</p><p>var wspeedS = 9.8;</p><p>var rotationS = 437;</p><p></p><p></p><p>var targetPro = 5;</p><p>var destinationDistance = 200;</p><p></p><p></p><p>// Difference between recording and movement of the object</p><p>private var lCT = 0.3;</p><p></p><p></p><p>// Current XZ dimention movement</p><p>private var simpleMov = Vector3.zero;</p><p>// Speed in horizontal axis</p><p>private var moveSpeed = 0.0;</p><p></p><p></p><p>// Last value controller</p><p></p><p></p><p>private var CollideIndicator : CollideIndicator; </p><p></p><p></p><p>// Backward mpvement as camera can't easily detect it</p><p>private var simpleB = false;</p><p>// Initialzing the key movements</p><p></p><p></p><p>private var littleisMove = false;</p><p></p><p></p><p>private var trueControll = true;</p><p></p><p></p><p>private var isTargetting : boolean = false;</p><p>private var targetPoint : Vector3 = Vector3.zero;</p><p></p><p></p><p>function Awake () {</p><p> simpleMov = transform.TransformDirection(Vector3.forward);</p><p></p><p></p><p> _custommovanim = GetComponent(Animation);</p><p> if(!_custommovanim)</p><p> Debug.Log("No animations for this character. Doing so, is not the suitable movement");</p><p></p><p></p><p> if(!idlemovement) {</p><p> _custommovanim = null;</p><p> Debug.Log("Can't see the pefect idle animes. It is recommended to turn off the animatsion");</p><p> }</p><p> _custommovanim[idlemovement.name] = idlemovement;</p><p></p><p></p><p> if(!walkscene) {</p><p> _custommovanim = null;</p><p> Debug.Log("0 walking. It is good, if you could turn off those animations");</p><p> }</p><p> _custommovanim[walkscene.name] = walkscene;</p><p>}</p><p></p><p></p><p>function UpdateSmoothedMovementDirection () {</p><p> var cameraTransform = Camera.main.transform;</p><p></p><p></p><p> // Relative camera movement </p><p> var forward = cameraTransform.TransformDirection(Vector3.forward);</p><p> forward.y = 0;</p><p> forward = forward.normalized;</p><p></p><p></p><p> // Relative camera xz moveemnt</p><p></p><p></p><p> // Getting orthogonal vector</p><p></p><p></p><p> var right = Vector3(forward.z, 0, -forward.x);</p><p></p><p></p><p> var v = Input.GetAxisRaw("Vertical");</p><p> var h = Input.GetAxisRaw("Horizontal");</p><p></p><p></p><p> // Getting backward movements of the scene</p><p> if (v < -0.2)</p><p> simpleB = true;</p><p> else</p><p> simpleB = false;</p><p></p><p></p><p> var wasMoving = littleisMove;</p><p> littleisMove = Mathf.Abs (h) > 0.1 || Mathf.Abs (v) > 0.1;</p><p></p><p></p><p> // Getting the relative direction from the user</p><p></p><p></p><p> var targetDirection = h * right + v * forward;</p><p></p><p></p><p> // Using the lock time for small glitches</p><p></p><p></p><p> lCT += Time.deltaTime;</p><p> if (littleisMove != wasMoving)</p><p> lCT = 0.0;</p><p></p><p></p><p> // Using different variables for speed and distance</p><p> // To get the real work of the standing character in the valid direction</p><p> // Getting normalization factor invovled in the small time</p><p> if (targetDirection != Vector3.zero) {</p><p> // Snapping the slow movement</p><p> if (moveSpeed < wspeedsimple * 0.9) {</p><p> simpleMov = targetDirection.normalized;</p><p> }</p><p> // In opposite case, smooth turn</p><p></p><p></p><p> else {</p><p> simpleMov = Vector3.RotateTowards(simpleMov, targetDirection, rotationS * Mathf.Deg2Rad * Time.deltaTime, 1000);</p><p> simpleMov = simpleMov.normalized;</p><p> }</p><p> }</p><p></p><p></p><p> // Current targest Smoothness</p><p></p><p></p><p> var curSmooth = wspeedS * Time.deltaTime;</p><p></p><p></p><p> // Carefully choosing the target in terms of speed</p><p> //* Small analog movements and carefully mentoring horizontal cases</p><p> var targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0);</p><p></p><p></p><p> _CstateChar = CstateChar.Idle;</p><p></p><p></p><p> // Configuring the speed modifier</p><p> targetSpeed *= wspeedsimple;</p><p> _CstateChar = CstateChar.Walking;</p><p></p><p></p><p> moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth);</p><p>}</p><p></p><p> // Smooth the speed based on the current target direction</p><p> var curSmooth = wspeedS * Time.deltaTime;</p><p> // Choose target speed</p><p> //* We want to support analog input but make sure you cant walk faster diagonally than just forward or sideways</p><p> var targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0);</p><p> _CstateChar = CstateChar.Idle;</p><p></p><p> // Pick speed modifier</p><p> targetSpeed *= wspeedsimple;</p><p> _CstateChar = CstateChar.Walking;</p><p> moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth); </p><p>}</p><p></p><p>function Update() {</p><p> if (!trueControll) {</p><p> // kill all inputs if not controllable.</p><p> Input.ResetInputAxes();</p><p> }</p><p></p><p> var distance : float = 0;</p><p> if (Input.GetMouseButtonUp(0)) {</p><p> if (isTargetting) {</p><p> isTargetting = false;</p><p> // Debug.Log("Stopped moving");</p><p> FaceCamera();</p><p> } else {</p><p> var ray = Camera.main.ScreenPointToRay(Input.mousePosition);</p><p> var layerMask = 1 << 8; // Terrain is layer 8</p><p> var hit : RaycastHit;</p><p> Physics.Raycast(Camera.main.transform.position, ray.direction, hit, 1000, layerMask);</p><p> distance = Vector3.Distance(transform.position, hit.point);</p><p> if (distance <= destinationDistance && hit.point != Vector3.zero) {</p><p> targetPoint = hit.point;</p><p> isTargetting = true;</p><p> // Debug.Log("Mouse up at hit " + hit.point + " at distance " + distance);</p><p> } else {</p><p> isTargetting = false;</p><p> // Debug.Log("Ignored mouse up at hit " + hit.point + " at distance " + distance);</p><p> }</p><p> }</p><p> }</p><p></p><p></p><p> if (isTargetting) {</p><p> // Debug.Log("Moving to " + targetPoint);</p><p> distance = Vector3.Distance(transform.position, targetPoint);</p><p> if (distance < targetPro) {</p><p> // Debug.Log("Reached point " + targetPoint + " at distance " + distance);</p><p> isTargetting = false;</p><p> FaceCamera();</p><p> } else {</p><p> UpdateTargettedMovementDirection();</p><p> }</p><p> } else {</p><p> UpdateSmoothedMovementDirection();</p><p> }</p><p></p><p></p><p> // Calculate actual motion</p><p> var movement = simpleMov * moveSpeed;</p><p> movement *= Time.deltaTime;</p><p></p><p></p><p> // Move the controller</p><p> var controller : CharacterController = GetComponent(CharacterController);</p><p> CollideIndicator = controller.Move(movement);</p><p></p><p></p><p> // ANIMATION sector</p><p> if (_custommovanim) { </p><p> if (controller.velocity.sqrMagnitude < 0.1) {</p><p> _custommovanim.CrossFade(idlemovement.name);</p><p> } else {</p><p> //_custommovanim[walkscene.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, maxmovspeed);</p><p> _custommovanim.CrossFade(walkscene.name); </p><p> }</p><p> } else {</p><p> Debug.Log("Animation is null!");</p><p> }</p><p> // ANIMATION sector</p><p></p><p></p><p> // Set rotation to the move direction</p><p> transform.rotation = Quaternion.LookRotation(simpleMov);</p><p>}</p><p></p><p></p><p>//Getters and setters for the whole scene</p><p></p><p></p><p>function FaceCamera() {</p><p> var cameraTransform = Camera.main.transform;</p><p></p><p></p><p> // XZ vector with relative forward movement</p><p> var forward = cameraTransform.TransformDirection(Vector3.forward);</p><p> forward.y = 0;</p><p> forward = forward.normalized;</p><p> simpleMov = -forward;</p><p>}</p><p></p><p></p><p>[/CODE]Update 2: Current are the settings, I am trying to configure.</p><p>[ATTACH]78156[/ATTACH]</p><p>[ATTACH]78157[/ATTACH]</p><p></p><p>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 <a href="http://militarybases.co/directory/aviation-training-center-coast-guard-base-in-mobile-al-2/" target="_blank">http://militarybases.co/directory/aviation-training-center-coast-guard-base-in-mobile-al-2/</a> 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.</p></blockquote><p></p>
[QUOTE="Laris Bania, post: 6937674, member: 6863508"] 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. [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; } [/CODE]Update 2: Current are the settings, I am trying to configure. [ATTACH=CONFIG]78156._xfImport[/ATTACH] [ATTACH=CONFIG]78157._xfImport[/ATTACH] 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 [URL]http://militarybases.co/directory/aviation-training-center-coast-guard-base-in-mobile-al-2/[/URL] 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. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
Unity problems with 3rd person ground control
Top