Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Toasticuss · Mar 18, 2014 at 08:41 PM · script errorthird-personcharacter controllingunity 4.3.4

Unity 4.3.4 completely freezes with third person script

Below is a very nice 3rd person camera script that I made following a tutorial on 3DBuzz. Whenever I put the TP_Controller.cs script on a biped or character and click play, the entire Unity 4 client freezes. I've tried contacting 3DBuzz to see if they could help see why Unity 4 is freezing but I've heard no response. Their forums are full of unanswered questions.

So is there anyone here that can test this on Unity 3 which is what 3DBuzz made it for. Or try it out for themselves to see why it's crashing? I don't even get a debug or error log message. It's just a hard freeze and I have to close Unity with TaskManager. It seems like there should be a failsafe built in to Unity avoid such a big crash.

To use the script all you need to do is attach TP_Camera, controller, and the motor C# scripts to a character. Make sure the helper.cs is with the other scripts. It'll automatically create a camera if one doesn't exist.

Helper.cs - http://pastebin.com/VwUghR0s

TP_Camera.cs - http://pastebin.com/X5JizCHE

TP_Controller.cs - http://pastebin.com/V5pHi1Mr

TP_Motor.cs - http://pastebin.com/NPGPEKkQ

Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Mar 18, 2014 at 08:42 PM 1
Share

If Unity freezing actually means Unity stops being responsive, this usually means one of the scripts has gotten into an infinite loop. The easy way to see this is to plaster Debug.Log() messages everywhere, and look and see if any of them come spewing out of your scripts.

avatar image Toasticuss · Mar 18, 2014 at 08:54 PM 0
Share

I went in and plastered Debug.Log all over the TP_Controller which is the script file in giving the problems. But the Console in the Unity editor freezes with Unity before it has a chance to say anything.

Is there any other way to debug this?

avatar image Toasticuss · Mar 18, 2014 at 10:50 PM 0
Share

I narrowed it down to line 15 in the TP_Controller.cs script.

Line 15 is -

 TP_Camera.UseExistingOrCreateNew$$anonymous$$ainCamera ();

Hmmm

1 Reply

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

Answer by Adamcbrz · Mar 19, 2014 at 01:38 AM

This is because your Helper.ClampAngle method.

These freezes are usually because of infinite loops.

I think you meant for it to be like this

 do
 {
      // If angle is less than 360 - add 360
      if (angle < -360)
         angle += 360;
         
      // If angle is greater than 360 - subtract 360
      if (angle > 360) /***** you had -360 ****/
         angle -= 360;
             
 } while (angle < -360 || angle > 360);
Comment
Add comment · Show 1 · 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 Toasticuss · Mar 19, 2014 at 01:49 AM 0
Share

AWESO$$anonymous$$E!!! Unity is no longer freezing but the camera is not following the character haha. Thanks a lot!

I also fixed a typo on line 145 in the TP_Camera.cs script.

UPDATE: I was missing an empty game object parented to the character named 'targetLookAt'. Now the camera follows the character.

Thanks a bunch!

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

22 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Why can't I pass in void when trying to connect scripts? 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Material doesn't have a color property '_Color' 4 Answers

Footstep sounds not coming up when walking? (MOBILE) 3 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