public override void SwitchModelAndView(string _modelName, bool _bFPV, bool _bMale) { Log("Running Switch and Model View"); this.SetBool("IsDead", this.entity.IsDead()); this.SetBool("IsAlive", this.entity.IsAlive()); // dummy assign body parts this.assignBodyParts(); Log(" Root Motion: " + this.entity.RootMotion); if (this.entity.RootMotion) { Log(" Root Motion is enabled."); AvatarRootMotion avatarRootMotion = this.bipedTransform.GetComponent <AvatarRootMotion>(); if (avatarRootMotion == null) { Log(" AvatarRootMotion() not found. Adding one."); avatarRootMotion = this.bipedTransform.gameObject.AddComponent <AvatarRootMotion>(); } Log(" Initializing Root Motion"); avatarRootMotion.Init(this, this.anim); } // Check if this entity has a weapon or not if (this.rightHandItemTransform != null) { Log("Setting Right hand position"); this.rightHandItemTransform.parent = this.rightHandItemTransform; Vector3 position = AnimationGunjointOffsetData.AnimationGunjointOffset[this.entity.inventory.holdingItem.HoldType.Value].position; Vector3 rotation = AnimationGunjointOffsetData.AnimationGunjointOffset[this.entity.inventory.holdingItem.HoldType.Value].rotation; this.rightHandItemTransform.localPosition = position; this.rightHandItemTransform.localEulerAngles = rotation; this.SetInRightHand(this.rightHandItemTransform); } this.SetInt("WalkType", this.entity.GetWalkType()); this.SetBool("IsDead", this.entity.IsDead()); this.SetBool("IsAlive", this.entity.IsAlive()); }
public override void SwitchModelAndView(string _modelName, bool _bFPV, bool _bMale) { //Debug.Log("MODEL NAME: " + _modelName); Transform transform = this.ModelTransform; if (transform == null) { if (_bFPV) { transform = this.ModelTransform.Find(_modelName); if (transform == null) { Log("SwitchModelAndView: Error finding transform!"); return; } } // no main transform, not continueing return; } //if (transform!=null) Debug.Log("TRANSFORM = " + transform.name); this.GraphicsTransform = transform; this.meshTransform = transform; this.modelName = _modelName; this.bMale = _bMale; this.bFPV = _bFPV; this.assignBodyParts(); try { this.anim = this.GraphicsTransform.GetComponent <Animator>(); if (this.anim == null) { Log("SwitchModelAndView: Animator not found!"); this.anim = this.GraphicsTransform.gameObject.AddComponent <Animator>(); Log("Added Animator"); // return; } } catch (Exception) { Log("No Animator, and could not attach"); //Debug.Log("NO ANIMATOR"); } try { if (this.entityAlive.RootMotion) { Log("Checking if Root MOtion is enabled"); AvatarRootMotion avatarRootMotion = this.ModelTransform.GetComponent <AvatarRootMotion>(); if (avatarRootMotion == null) { avatarRootMotion = this.ModelTransform.gameObject.AddComponent <AvatarRootMotion>(); } avatarRootMotion.Init(this, this.anim); } } catch (Exception) { Log("Root Motion is not available."); } if (this.rightHandItemTransform != null) { Debug.Log("Setting Right Hand Item Transform"); this.rightHandItemTransform.parent = this.rightHand; Vector3 position = AnimationGunjointOffsetData.AnimationGunjointOffset[this.entityAlive.inventory.holdingItem.HoldType.Value].position; Vector3 rotation = AnimationGunjointOffsetData.AnimationGunjointOffset[this.entityAlive.inventory.holdingItem.HoldType.Value].rotation; this.rightHandItemTransform.localPosition = position; this.rightHandItemTransform.localEulerAngles = rotation; SetInRightHand(this.rightHandItemTransform); } if (this.anim != null) { this.anim.SetBool("IsMale", _bMale); this.anim.SetInteger("WalkType", this.entityAlive.GetWalkType()); this.anim.SetBool("IsDead", this.entityAlive.IsDead()); this.anim.SetBool("IsFPV", this.bFPV); this.anim.SetBool("IsAlive", this.entityAlive.IsAlive()); } Log("Done with SwichModelAndView"); }
void Awake() { Log("Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name); try { this.GraphicsTransform = this.transform.Find("Graphics"); if (this.GraphicsTransform == null) { Log(" !! Graphics Transform null!"); this.HasDied = true; return; } this.ModelTransform = this.GraphicsTransform.Find("Model").GetChild(0); if (this.ModelTransform == null) { Log(" !! Model Transform is null!"); this.HasDied = true; return; } //this bit is important for SDXers! It adds the component that links each collider with the Entity class so hits can be registered. AddTransformRefs(this.ModelTransform); //if you're using A14 or haven't set specific tags for the collision in Unity un-comment this and it will set them all to being body contacts //using this method means things like head shot multiplers won't work but it will enable basic collision AddTagRecursively(this.ModelTransform, "E_BP_Body"); Log("Searching for Idle"); // Searchs for the animator this.anim = FindAnimator(this.ModelTransform); if (this.anim == null) { Log("*** Animator Not Found! Invalid Class"); throw (new Exception("Animator Not Found! Wrong class is being used! Try AnimationSDX instead...")); } Log("Animator is: " + this.anim.enabled.ToString()); this.anim.enabled = true; //else //{ // Log("Loading MyAnimationController"); // RuntimeAnimatorController runtimeAnimController = (RuntimeAnimatorController)Resources.Load("MyAnimationController"); // this.anim.runtimeAnimatorController = runtimeAnimController; // Log("MyAnimationController Loaded"); //} //Log("Number of Animations: " + this.anim.runtimeAnimatorController.animationClips.Length.ToString() ); Log("Searching for Root Motion"); if (this.entityAlive.RootMotion) { AvatarRootMotion avatarRootMotion = this.ModelTransform.GetComponent <AvatarRootMotion>(); if (avatarRootMotion == null) { Log("Root MOtion not detected. Creating AvatarRootMotion"); avatarRootMotion = this.ModelTransform.gameObject.AddComponent <AvatarRootMotion>(); } Log("Initializing Root Motion"); avatarRootMotion.Init(this, this.anim); } } catch (Exception ex) { Log("Exception thrown in Awake() " + ex.ToString()); } }