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 question was closed Apr 21, 2013 at 02:46 AM by Bunny83 for the following reason:

Duplicate Question:

http://answers.unity3d.com/questions/441125/c-teleport-script-error.html

avatar image
0
Question by Ochreous · Apr 20, 2013 at 09:04 PM · c#teleport

C# Instant Teleport Script

Hi everyone, how do I make it so the script instantly teleports + 0.7 in the z axis? I tried transform.position.z += 0.7 but I get a cannot modify value error.

Comment
Add comment · Show 4
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 asafsitner · Apr 20, 2013 at 09:17 PM 0
Share

transform.position = transform.position + new Vector3(0, 0, 0.7f);

You get that error because C# doesn't let you access the vector components individually, you have to replace the whole vector.

avatar image kmeboe · Apr 21, 2013 at 12:53 AM 0
Share

Surely you're just $$anonymous$$sing us now?

http://answers.unity3d.com/questions/441125/c-teleport-script-error.html

avatar image Bunny83 · Apr 21, 2013 at 02:46 AM 0
Share

@kmeboe: Well done ;) I can't even remember the question although i posted a quite detailed explanation yesterday :D

I will close this one

avatar image kmeboe · Apr 21, 2013 at 03:53 AM 0
Share

:D

We all have memory issues now and again.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Howey-Do-It · Apr 20, 2013 at 10:26 PM

Transform.position.x/y/z is a read-only property. You can't modify it directly.

This should work if I understand the question correctly. By setting the X and Y values to the current position it is simply not modifying them, in case the object is not stationary on the other axes. Which I am guessing is the case.

transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.7f);

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

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

C# Teleport Script Error 1 Answer

C# Instant OnTriggerEnter Detection 0 Answers

C# GUI.Tooltip If Statement 2 Answers

C# SetActive GameObject Array 2 Answers

unity c# RPC 0 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