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 /
This question was closed Oct 30, 2014 at 02:30 AM by eeveelution8 for the following reason:

Problem is not reproducible or outdated

avatar image
1
Question by eeveelution8 · May 19, 2014 at 01:08 AM · collisionmovementaijavadetection

Use of an AI script, and having it NOT go through walls using a character controller

This questions arises from a different question regarding an AI script and is a continuation of the topic. While functional, has the enemy its used on go through walls. This is problematic on several levels, unless the enemy is a ghost.

A fellow used suggested rescripting the script without using transform.translate, and instead use character controllers and their functions. here is what it looks like so far...

     var distance = 0.00;
     var target : Transform;    
     var lookAtDistance = 15.0;
     var attackRange = 10.0;
     var moveSpeed = 5.0;
     var damping = 6.0;
     var controller : CharacterController;
     var forward : Vector3;
     var curSpeed : float = 1;
 
 
     function Start(){
     
     controller = GetComponent(CharacterController);
     forward = transform.TransformDirection(Vector3.forward);
     }
 
     function Update () 
     {
     distance = Vector3.Distance(target.position, transform.position);
  
     if(distance < lookAtDistance)
     {
 
 
     lookAt ();
     }   
     if(distance > lookAtDistance)
     {
 
     }
     if(distance < attackRange)
     {
     NextPos = target.position;
     attack ();
     }
 }
  
  
 function lookAt ()
 {
 var rotation = Quaternion.LookRotation(target.position - transform.position);
 transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
 }
  
 function attack ()
 {
     controller.Move(forward * curSpeed);
 }
  
 


It still does not work, and I'm seeking assistance with it, I'm not asking for someone to write the script for me as some people dislike, I'm looking for what parts of the script are wrong and how to fix it. The problem now is that it does not move.

Comment
Add comment · Show 2
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 jmparavicini · Oct 30, 2014 at 01:53 AM 0
Share

I suggest using navmesh and setDestination

avatar image eeveelution8 · Oct 30, 2014 at 02:29 AM 0
Share

Hey thanks for re$$anonymous$$ding me this question still was open, i forgot to close it because I have long since made a better AI

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

21 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

Related Questions

How can I make it so that my player only moves if there is no wall in the direction he wishes to move? 1 Answer

How can I make a non-player character (rigidbody) move when they touch the ground? 1 Answer

help with AI avoidance script 0 Answers

check if two colliders Rub against each other 1 Answer

How to make object move away from nearby objects 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