Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by scottsniper77 · Apr 12, 2016 at 03:52 PM · respawnresources.loadrespawner

Why is my player not being found after being respawned

Here is my script:

 var Distance;
 var Target : GameObject;
 var lookAtDistance = 25.0;
 var chaseRange = 15.0;
 var attackRange = 1.5;
 var moveSpeed = 5.0;
 var Damping = 6.0;
 var attackRepeatTime = 1;
 var MaxHealth = 100;
 var Health : int;
 
 var TheDammage = 40;
 
 private var attackTime : float;
 
 var controller : CharacterController;
 var gravity : float = 20.0;
 var rigidbdy : Component;
 private var MoveDirection : Vector3 = Vector3.zero;
 
 function Awake () {
     Target = Resources.Load("Player/FPScontroller 1", GameObject) as GameObject;
 }
 
 function Start ()
 {
     attackTime = Time.time;
     Health = MaxHealth;
     GetComponent.<Rigidbody>().isKinematic = true;
     GetComponent.<Rigidbody>().detectCollisions = false;
 
 }
 
 function Update ()
 {
     if(RespawnMenuV2.playerIsDead == false)
     {
         Distance = Vector3.Distance(Target.transform.position, transform.position);
         
         if (Distance < lookAtDistance)
         {
             lookAt();
         }
         
         if (Distance > lookAtDistance)
         {
             GetComponent.<Renderer>().material.color = Color.green;
         }
         
         if (Distance < attackRange)
         {
             attack();
         }
         else if (Distance < chaseRange)
         {
             chase ();
         }
     }
 }
 
 
 function ApplyDammage (TheDammage : int)
     {
         Health -= TheDammage;
         if(Health <= 0)
         {
             Dead();
         }
     }
 function Dead()
     {
         GetComponent.<Rigidbody>().isKinematic = false;
         GetComponent.<Rigidbody>().detectCollisions = true;
         PlayerStatsV2.zombieskilled ++;
         PlayerHumanity.humanity ++;
         Destroy(this);
     }
 function lookAt ()
 {
     GetComponent.<Renderer>().material.color = Color.yellow;
     var rotation = Quaternion.LookRotation(Target.transform.position - transform.position);
     transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
 }
 
 function chase ()
 {
     GetComponent.<Renderer>().material.color = Color.red;
     
     moveDirection = transform.forward;
     moveDirection *= moveSpeed;
     
     moveDirection.y -= gravity * Time.deltaTime;
     controller.Move(moveDirection * Time.deltaTime);
 }
 
 function attack ()
 {
     if (Time.time > attackTime)
     {
         Target.SendMessage("ApplyDammage", TheDammage);
         Debug.Log("The Enemy Has Attacked");
         attackTime = Time.time + attackRepeatTime;
     }
 }
 
 function ApplyDammage ()
 {
     chaseRange += 30;
     moveSpeed += 2;
     lookAtDistance += 40;
 }


I get this error loads of times:

 NullReferenceException: Object reference not set to an instance of an object
 AdvancedAIV2.Update () (at Assets/Zombies/AI/AdvancedAIV2.js:38)




Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by scottsniper77 · Apr 12, 2016 at 06:39 PM

nevermind found a way around this

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Grehgh · Sep 25, 2021 at 03:11 PM

This is the equivalent of https://xkcd.com/979/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

ThePlayer should respawn at his start position after his health drops down to 0. However it doesn't work properly. Can somebody tell me what went wrong and how to fix it please? 0 Answers

Respawn doesn't work ? 0 Answers

Time delay enemy respawn 3 Answers

types of objects 1 Answer

Bizarre Respawn Bug 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges