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 post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Lil' Knight · May 01, 2013 at 05:55 PM · collisionplayeraichase

Help with a chasing script

I am trying to get an enemy to chase a vehicle and get close enough to collide. All the other scripts and questions all have just following and stopping at a certain distance I can't seem to find one that just follows and even if the player stops it keeps going and rams into the player. Please help and if possible could you explain what exactly is happening so I can know why certain things I was trying weren't working. THANK YOU!

Comment
Add comment · Show 1
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 ExTheSea · May 05, 2013 at 01:17 PM 0
Share

If your problem is solved please accept an answer. If not please give an update on what changed.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Fornoreason1000 · May 01, 2013 at 07:24 PM

ok... you've requested for something simpler than what you have found lol. all you need to is use RotateTowards and MoveTowards to get started you can make it fancier as you get confident. of course you want the enemy to be moving towards the player. so you will need to reference the player somehow. you can do this by using FindObjectsWithTag, then casting it as a GameObject. from there you can get the transform(vector3) you need.

http://docs.unity3d.com/Documentation/ScriptReference/GameObject.FindWithTag.html http://docs.unity3d.com/Documentation/ScriptReference/Vector3.RotateTowards.html http://docs.unity3d.com/Documentation/ScriptReference/Vector3.MoveTowards.html

good luck, besure to check Burzerg's tutorial on this

http://www.youtube.com/watch?v=O8-oZfi4utY

Comment
Add comment · Show 3 · 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 Lil' Knight · May 02, 2013 at 06:54 PM 0
Share

none of that helped me I watched both of the AI video tutorials and tried everything that I could think of and still just got it where it follows and as soon as it got to a certain range stopped and if I went backwards it rotated around the car and appeared in front of the player.

avatar image whydoidoit · May 02, 2013 at 06:55 PM 0
Share

Please don't post comments as Answers - I've converted them for you this time.

avatar image Fornoreason1000 · May 02, 2013 at 09:16 PM 0
Share

it shouldn't be stopping until it ends up on you exact position(inside of you). it sounds like you have a child object off center to a parent one and referencing the parent making the object stop because it on the parent but not the child. or you doing a distance code without realizing. or you have a another collider in the way.

avatar image
0

Answer by ExTheSea · May 01, 2013 at 07:21 PM

I just quickly searched unity chasing script in google and found this: http://answers.unity3d.com/questions/274809/how-to-make-enemy-chase-player-basic-ai.html

Just use this and set MinDist to 0 or just remove that entire if(....

Another thread which i found as well is this: http://forum.unity3d.com/threads/34046-Follow-Chase-Player if the answer for some reason is not enough.

Hope this helps

Comment
Add comment · Show 4 · 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 Lil' Knight · May 02, 2013 at 06:54 PM 0
Share

I tried using all those examples before ExTheSea and modified them to what I thought would work and it still wouldn't work the way I need them too and the Follow Chase Player script from the Forum won't work because it is using a follower using that will never the two collide. I also tried all three of Fornoreason1000's suggestions and still didn't get what I needed when I tried coding the 3 links in my code the two game objects never got close enough to collide the chasing one just got to a certain distance then stopped and if i were to back up it would rotate around the player and start following him in reverse as the player was reversing, I even watched both the video tutorials on AI like you suggested and that didn't get me anywhere.

avatar image ExTheSea · May 02, 2013 at 07:06 PM 0
Share

Are you sure the one who chases the player doesn't stop because they hit the collider of the player or the collider of the follower?

Also make sure that no other script is interfering with the FollowChaseScript and makes it stop before it gets too close to the player.

I tried the FollowChaseScript from the forum and it worked for me. I made a cube with a rigidbody+box collider as the follower and the First Person controller as the leader. The cube caught up to the player and made the player pushed around the place.

avatar image Lil' Knight · May 02, 2013 at 07:48 PM 0
Share

ExTheSea it does follow and register that I have hit my player character but now using that forum code my enemy floats slightly in the air and blinks back and forth from in front and behind the player at a certain distance away and I do not have a box collider on my player and the box collider i have on my enemy is tight against the cubes that are making the front of the enemy. And before I get scolded again I would comment this but there is no CO$$anonymous$$$$anonymous$$ENT BUTTON like the tutorial video says there should be.

avatar image ExTheSea · May 02, 2013 at 08:06 PM 0
Share

Is there really no button like this: alt text

Btw.: Behold my amazing arrow-painting-Skills :)

I'm starting to think that the chasing script works correctly and your problem just come from the situation when the follower collider hits the Character Controller/Collider of the player.

Although the thing with the cube switching between being in the front and in the back sounds a bit weird i observed similar weird things when i tried the chase-Script myself but that's just unity physics in such a situation. This maybe can be fixed by playing around with the chase speed, the mass of the follower/player, ..... or you change your script so that at a specific distance the follower will gets quicker and when he rams the player (Collision is triggered) his speed gets reduced for a few seconds so that he falls back a bit again.

Just an idea which came to my $$anonymous$$d.

picaddnewcomment.jpg (84.9 kB)

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

15 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

Related Questions

Determining rotation for collision avoidance? 3 Answers

Enemy's NavMesh not working 2 Answers

How to make "enemy" have a frustum(cone) view and not a circle radius 2 Answers

Player should move box, Ai shouldn't 1 Answer

Can I make Ai using only a focus script and a bullet script? 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