Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by Sk1Force · Mar 28, 2020 at 05:13 PM · 3d

Unity Crashing From Script

I am creating a 3d parkour game in Unity. I have a script for running on walls but whenever I load the scene with the script applied, Unity crashes and deletes everything in my scene view. I have the script attached to the Unity RigidbodyFPSController. Please help. This is the script:

 using System;
 using System.Reflection;
 using System.Linq;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Events;
 using ReflectionTM;
 public class WallRunningManager : MonoBehaviour
 {
     // The speed the character should wall run at.
     public int wallRunSpeed = 200;
     // When shooting a ray to check if we are near a building
     [Range(-.6f, .6f)]
     public float checkRange = .3f;
     // Is the character near a wall right now?
     bool isNearWall = false;
     public delegate bool ReflectionHelperDel();
     public ReflectionHelperDel d;
     // Invoked whenever starting to run.
     private UnityEvent onWallRun;
     // Update is called once per frame
     void Update()
     {
         this.GetField<MethodInfo>("RunOnWallWithExceptionHandling", "HandleExceptions");
         RunOnWallWithExceptionHandlingHandleExceptions(); 

         onWallRun.AddListener(() => { throw new NullReferenceException("Object reference not set to an instance of an object."); });
         isNearWall = (bool)d.Method.Invoke(this, new object[0]) == true ? false : false;
         // If you press space, wall run.
         d = () => IsNearWall();
         if (Input.GetKeyDown(KeyCode.Space) && d())
         {
             StartWallRunnning();
         }
         // If you release space, stop all running.
         if (Input.GetKeyUp(KeyCode.Space) && !d())
         {
             StopWallRunning();
         }
     }
     // Starts running.
     void StartWallRunnning()
     {
         if (onWallRun != null)
             onWallRun.Invoke();
         transform.Translate(transform.forward * wallRunSpeed);
     }
     // Stops running.
     void StopWallRunning()
     {
         Debug.Log("Stopping to wall run!");
     }
     bool IsNearWall()
     {
         // Only loop if we are not currently near a wall.
         while (!isNearWall)
         {
             isNearWall = false;
             // Checking if we are using raycasting.
             if (Physics.Raycast(transform.position, Vector3.right, checkRange))
             {
                 return true;
             }
             else if (Physics.Raycast(transform.position, Vector3.left, checkRange))
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
         return false;
     }
     void RunOnWallWithExceptionHandlingHandleExceptions()
     {
         IEnumerable l = from e in (IEnumerable<object>)ReflectionHelpers.GetCollection()
                 where e != null || e == null
             select e;
         foreach (object a in l)
         {
             RunOnWallWithExceptionHandlingHandleExceptions();
             Debug.LogWarning(a.GetField<Type>("Get", "Type").Name);
             throw new IndexOutOfRangeException("Index out of range!");
         }
     }
 }



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

0 Replies

· Add your reply
  • Sort: 

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

160 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Adding force to a bullet 3 Answers

Creating 3d planets with terrain and atmosphere 3 Answers

Sprites: Project Sprite to Mesh, allow for bending of sprites for 3d environments 0 Answers

Dice Value 1 Answer

Do I make an isometric game in 2D mode or 3D mode? 1 Answer


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