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 joeyg · May 21, 2012 at 01:08 PM · aienemyrespawn

Respawn with enemy contact

Hi all, I am a complete beginner at unity with a limited knowledge of coding, I am making a simple maze game and using this tutorial >> http://dma.canisius.edu/~moskalp/tutorials/FollowPlayer/followPlayer.mov have made an object that Im using as the enemy to follow the Player when they get within a certain distance.

I then watched this tutorial http://www.youtube.com/watch?v=xLiSPL2rG3U&feature=fvwrel where he shows how you can make the player respawn when they enter the cube but when I make my cube object "OnTrigger" It falls straight through the ground.

My plan is to make the enemy object respawn the player at the beginning of the maze when they catch up with the player and touch them but I'm getting confused and was wondering if anyone had any suggestions, they would be greatly appreciated thanks!

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 KiraSensei · May 21, 2012 at 01:14 PM 0
Share

Your problem is that the cube object falls through the ground ?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by ExTheSea · May 21, 2012 at 01:21 PM

From what i read i think you probably checked IsTrigger what results in ´the object falling through the ground.

You should use a script and probably tags. This is how i would do it.

Make a script and attach it to the players object and write something like this in it:

 function OnCollisionEnter(collision : Collision)
 {
 if(collision.gameObject.tag=="enemy")
    {
       //Here RespawnScript like for example: gameObject.transform.position=Vector3(0,0,0);
    }
 }

Then you have to set the tag of the enemy Objects to enemy. Btw. the script is not perfect and you may have to tweak it if you need help with it or if its not working comment and i'll help you or someone else does.

Hope this works.

Comment
Add comment · Show 8 · 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 joeyg · May 21, 2012 at 02:06 PM 0
Share

Hey there, Well done for working out what i was trying to do, I realise now my question a bit unclear. I have tagged the enemy and replaced the (0,0,0) with the coordinates of my player's starting position (was this the wrong thing to do?), It picks up when the player and enemy collide which is brilliant but I then get an error message saying: $$anonymous$$issingFieldException: Field 'UnityEngine.GameObject.position' not found. So i'm guessing everything works perfectly except the respawn script as you predicted but I'm not sure what i would do Thank you this is unbeleivably helpful!

avatar image ExTheSea · May 21, 2012 at 02:30 PM 0
Share

oh yeah right i messed that up a bit try using gameobject.transform.position(your spawnposition).

avatar image joeyg · May 21, 2012 at 05:28 PM 0
Share

brilliant thanks!

avatar image ExTheSea · May 21, 2012 at 06:34 PM 1
Share

Would you $$anonymous$$d marking this answer as accepted so that the question doesn't get displayed in unanswered questions anymore.

I'm happy that i did help you.

avatar image ExTheSea · May 22, 2012 at 03:31 PM 0
Share

To get a question marked as answered you have to click that button under the thumbs up and down-thing. When you're not doing this people might think it's not answered.

Show more comments

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Send an enemy back to its spawn point using waypoints 2 Answers

How to make this enemy script shoot upwards? 1 Answer

2D Random AI 1 Answer

free roaming enemy ai 1 Answer

enemy respawn after amount of time 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