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 Krimzen · May 19, 2013 at 11:49 AM · aiblenderrpgartificialintelligence

My model from Blender does not follow the AI script properly!

Well I've been making my first unity game, and I've encountered this issue where in game objects, like capsules, will follow the correct AI in the script, however. My imported model from blender does not follow it properly, it works fully, except the part where it's actually supposed to follow me around, seen here in my update video: http://youtu.be/GBU-SYiDFtI?t=54s (Starts at the point of the issue) (I tried adding that controller line into the start function, no difference at all) Screenshot: http://img811.imageshack.us/img811/1608/screenshot20130520at928.png My code looks like this

 var Distance;
 var Target : Transform;
 var lookAtDistance = 25.0;
 var chaseRange = 15.0;
 var attackRange = 1.5;
 var moveSpeed = 3.0;
 var Damping = 6.0;
 var controller : CharacterController;
 var gravity : float = 20.0;
 private var moveDirection : Vector3 = Vector3.zero;
 
 var attackRepeatTime = 1;
 var TheDamage = 20;
 private var attackTime : float;
 
 function Start()
 {
     attackTime = Time.time;
 }
 
 function Update ()
 {
     Distance = Vector3.Distance(Target.position, transform.position);
     
     if (Distance < lookAtDistance)
     {
         lookAt();
     }
     
     if (Distance < attackRange)
     {
         attack();
     }
      else if (Distance < chaseRange)
     {
         chase ();
     }
 }
 
 function lookAt ()
 {
     var rotation = Quaternion.LookRotation(Target.position - transform.position);
     transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
 }
 
 function chase ()
 {
     moveDirection = transform.forward;
     moveDirection *= moveSpeed;
     
     moveDirection.y -= gravity * Time.deltaTime;
     controller.Move(moveDirection * Time.deltaTime);
 }
 
 function attack ()
 {
     if (Time.time > attackTime)
     {
         Target.SendMessage("ApplyDamage", TheDamage);
         Debug.Log("Enemy has attacked");
         attackTime = Time.time + attackRepeatTime;
     }
 }
 
 function applyDamage ()
 {
     chaseRange += 30;
     moveSpeed += 2;
     lookAtDistance +=40;
 }

Please help me, this is really halting my progress! D:

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

Answer by sparkzbarca · May 19, 2013 at 01:22 PM

thats because controller is a special object which uses a capsule.

Basically your issue is this part here

controller.Move(moveDirection * Time.deltaTime);

that'd be fine except that your imported object doesn't have a character controller attached i'm betting.

thats because if your object did it'd have a capsule around it and your saying it doesnt have a capsule. Character controllers only work with the capsule attached to them.

You can of course select your imported model and add a character controller to it.

Comment
Add comment · Show 5 · 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 Krimzen · May 19, 2013 at 09:29 PM 0
Share

I've already done that, I even went and removed the existing one and put another one onto, still nothing, any more ideas?!

avatar image sparkzbarca · May 20, 2013 at 02:42 AM 0
Share

oh I see the issue.

You didn't initialize the character controller

start() { controller = CharacterController; }

you created an empty character controller object but didn't assign it to the gameobjects controller.

avatar image Loius · May 20, 2013 at 03:58 AM 0
Share

controller = GetComponent(CharacterController)

avatar image AlucardJay · May 20, 2013 at 07:33 AM 0
Share

Ins$$anonymous$$d of leaving us all to guess, how about you supply a screenshot, showing your model in the scene, selected so that the collider is visible, and with the inspector visible so the objects' setup is visible. That would save a lot of guesswork ....

avatar image Krimzen · May 20, 2013 at 11:33 AM 0
Share

I updated my question :)

avatar image
0

Answer by Bunnybomb7670 · May 19, 2013 at 09:38 PM

Make sure your models forward is forward, that may be the issue.

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 Krimzen · May 19, 2013 at 10:31 PM 0
Share

If it wasn't forward, it's face wouldn't rotate towards me in the video, another side of it would, and it would move sideways if that was the only problem.

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

17 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

Related Questions

BDI Agent Programming in Unity3D 1 Answer

need a logical tip for AI 2 Answers

Tutorials for AngryAnt's Behave 1 Answer

AI in Untiy, best practices 1 Answer

Artificial Intelligence 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