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 kyogretcg · Jul 31, 2013 at 07:47 PM · chasemonster

How do I make my monster chase me?

Hi I want to know how to do the scripting for a slender type game more specifically I am trying to have my monster randomly walk around the map without passing through walls and once you come into a certain distance from it while looking at it the monster will begin to chase you and also i need a way that you can outrun it by getting a certain distance away at which time it will resume randomly walking around the map. I have a simple follow script here:

var target : Transform; var moveSpeed = 3; var rotationSpeed = 3; var myTransform : Transform;

function Awake(){ myTransform = transform; }

function Start(){ target = GameObject.FindWithTag("Player").transfo­rm; }

function Update () { myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); myTransform.position += myTransform.forward moveSpeed Time.deltaTime; }

I tested it and it works but I want it to also walk around the map instead of being in a fixed position then once it sees me it chases me. any help is appreciated. Thanks in advance.

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 nixcs2512 · Jul 31, 2013 at 08:52 PM 0
Share

You only need 1 boolean variable more to control that, in example:

    if(seeplayer)
     //chase player
     else
     //go around

Actually you need some ways to handle the "seeplayer" boolean, maybe put a trigger sphere collider to the ghost, if the player collide with the trigger, the boolean will set to true; or calculate the distance between player and ghost, if it smaller than a value,say 50, the boolean will set to true;...

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by danilonishimura · Jul 31, 2013 at 09:34 PM

kyogretcg,

It seems to me that you're looking for a fast solution to your problem, and as far as I can tell you, there is no such thing as "SimpleSlenderScript".

You may consider breaking the whole problem in parts and try to do them one by one. Make the enemy walk around the way you think it should move, then make it look around, then make it chase you when he finds you. The implementation depends from project to project. This probably will help you to get started: http://docs.unity3d.com/Documentation/Manual/CreatingGameplay.html

Good luck ;)

Comment
Add comment · 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

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

How could I make the AI follow me after chase = true?we 1 Answer

Item drop on monster kill 1 Answer

Enemy AI Problem 0 Answers

how to: continue invoking when the first object is destroyed 2 Answers

Enemy's NavMesh not working 2 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