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 Lewenos 1 · Apr 24, 2011 at 06:27 PM · errorteleportmmorpgclicktomove

When near object, able player to click it and then player teleports.

Hi everyone! Im making MMORPG game like runescape and im using portals to teleport from place to other. I need help with script and it would be something like..

var distance : float;

function update () {

if(Input.GetMouseButtonUp(0)) //Here what distance it needs to be that player is able to teleport. //Here teleport player..

//Teleport distance is something like if(distance < 3.0); and then player is able to teleport.

But i tried to search about this and tried to make script myself.. But i cant make it like that! Debug Console gives me so much errors that sometimes my computer does "Dump Error"!

So, i ask you everyone.. Please make me script that teleports me when im near enough (3.0) and when i click teleport.

Thank you very much!

Lewenos

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by FLASHDENMARK · Apr 24, 2011 at 06:35 PM

var distance; var canTeleport = false; var teleporter : Transform; // The teleporter goes here.

function Update () { distance = Vector3.Distance(teleporter.position, transform.position)

if(distance < 3) { canTeleport = true; } else {
canTeleport = false; } if(canTeleport && Input.GetButtonDown("Fire1")) { //Change position here.
} }

Now it should be fixed. If not please tell and I will actually grab it by the horns and test it.

Comment
Add comment · Show 18 · 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 Lewenos 1 · Apr 25, 2011 at 09:43 AM 0
Share

Thanks! This helps my alot!

avatar image Lewenos 1 · Apr 25, 2011 at 09:53 AM 0
Share

I just added some variables.. :)

Like: var destination : Transform; var Player : Transform;

And then:

if(distance < 3 && Input.GetButtonDown("Fire1")) { Player.transform.position = destination.position; } }

avatar image Lewenos 1 · Apr 25, 2011 at 10:00 AM 0
Share

And, some things needs fixing.. Like i can teleport anywhere.. Always when i click "fire1", i got teleported. And then it needs to be something like when i click THAT OBJECT, i will teleport.

Thanks, i will wait for answer. :)

I hope you can help me.

Lewenos

avatar image FLASHDENMARK · Apr 25, 2011 at 11:22 AM 0
Share

If you can wait a few hours I will correct the mistakes. Right now I am at a birthday party and I only got my Android device with me, but I will correct the code when I get home :)

avatar image Lewenos 1 · Apr 25, 2011 at 11:49 AM 0
Share

Ok, thanks, you are best :D

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

No one has followed this question yet.

Related Questions

How to teleport a gameobject using tags instead of setting 1 game object each to respawn point?[SOLVED] 2 Answers

Z Vector Teleportation Help 0 Answers

The type or namespace name 'ClickedEventArgs' could not be found (are you missing a using directive or an assembly reference?) its part of the steamvr_teleport script.how do i solve it? 0 Answers

Click to move script, need help. 1 Answer

OnMouseEnter Error 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