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 mwoodington · Aug 02, 2012 at 06:35 AM · playerenemyspawnteleporthorror

How to make enemy teleport right next to player?

I am making a horror game and was wondering how to make an enemy appear (teleport) right next to the player, to scare them. There is only one enemy in the house, so i need the enemy to teleport instead of just spawning next to the player. Any ideas on how to do this?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Radon · Aug 03, 2012 at 01:28 AM

     function Update () {
     transform.position = Vector3(X, Y, Z); //change x, y, z to where you want 
     yieldWaitForSeconds(2);
     transform.position = Vector3(X, Y, Z); //change x, y, z to somewhere where it's not visible for your controller. 
       } 
     }
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
avatar image
0

Answer by Radon · Aug 02, 2012 at 06:39 AM

I'm not sure if this works. I just wrote it down. But try it. If not, I will give you another way.

 function Update ()
 {
  transform.position = Vector3(X, Y, Z); //change x, y, z to where you want
 }
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 mwoodington · Aug 02, 2012 at 08:07 PM 0
Share

Is there any way I can make it so the enemy only appears for a split second and then disappears?

avatar image Radon · Aug 03, 2012 at 01:27 AM 0
Share

You could use the yield WaitForSeconds(2); and give it a new command or function or even repeat the above code with different coords like this.

function Update () { transform.position = Vector3(X, Y, Z); //change x, y, z to where you want yield WaitForSeconds(2); function Update () { transform.position = Vector3(X, Y, Z); //change x, y, z to somewhere where it's not visible for your controller. } }

avatar image mwoodington · Aug 03, 2012 at 05:19 PM 0
Share

I was kind of hoping I could gear it more towards this question. I made a new question to try and clarify before you posted.

http://answers.unity3d.com/questions/295136/make-enemy-appear-in-front-of-player-and-then-disa.html

avatar image
0

Answer by djfunkey · Oct 05, 2012 at 07:52 AM

     public Transform ScaryMonster;
     public Transform ScaredPlayer;
     public int FirstAppear = 0;
     
     private int MonsterStayTime = 1;
     public int Random1;
     public int Random2;
     private Random RandomTime;
     
     void Update ()
     {
         RandomTime = Random.Range(Random1, Random2);
         FirstAppear += Time.time;
         
         if (FirstAppear = 20)
         {
             Transform scarymonster;
             scarymonster = Instantiate (ScaryMonster, ScaredPlayer.position, scarymonster.LookAt(ScaredPlayer)) as Transform;
             Destroy (ScaryMonster, MonsterStayTime);
             Random1 = 30;
             Random2 = 40;
         }
         if (RandomTime <= Time.time)
         {
             scarymonster = Instantiate (ScaryMonster, ScaredPlayer.position, scarymonster.LookAt(ScaredPlayer)) as Transform;
             Destroy (ScaryMonster, MonsterStayTime);
             Random1 = 80;
             Random2 = 90;
         }
         if (RandomTime <= Time.time)
         {
             scarymonster = Instantiate (ScaryMonster, ScaredPlayer.position, scarymonster.LookAt(ScaredPlayer)) as Transform;
             Destroy (ScaryMonster, MonsterStayTime);
             Random1 = 120;
             Random2 = 130;
         }
         /* you get the drift, you just have to copy the above code multiple times for how ever many times you want */
     }
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
avatar image
0

Answer by Rixterz · Aug 29, 2013 at 12:07 AM

You could attach this to your enemy:

 var Player : Transform;
 function Start(){
 Teleport();
 }
 function Teleport(){
 yield WaitForSeconds(10);
 transform.position = Vector3(Player.position.x - 5, Player.position.y - 5, Player.position.y);
 yield WaitForSeconds(0.5);
 renderer.enabled = false
 }

This will wait for 10 secs, then teleport behind the player for 0.5 secs, then hide. To make the enemy teleport in front of the player, change "- 5" to "+ 5"

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

9 People are following this question.

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

Related Questions

How can I spawn enemies while leaving a gap for the player to advance? 1 Answer

How to make Enemy on scary game ? 1 Answer

How to make an enemy teleport? 3 Answers

Teleport Script by KeyDown for fast Level testing 2 Answers

Need help with my enemy spawn 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