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 pvpoodle · Nov 11, 2013 at 03:26 PM · transformpositionwaypointmove to

instant move an object to a position + offset value

hi,

im trying to use the seek steer script from the unity wiki. i want it to follow the player object by an offset value.

eg : steer to a point just a little above and behind the player.

im using an empty game object called waypoint and updating it to the player position.

the script works fine when i assign the player transform directly to the waypoint every fixed update()

as

     player = GameObject.FindGameObjectWithTag("Player");
     waypoint.transform = player.transform

or

 waypoint.transform.position = player.transform.position;

however i am unable alter the position with offset.

i have tried to assign waypoint.transform.position with player x,y,z coodinates and also the transform.translate() both to no avail.

i would appreciate a code with an example of how to do this.

thanks and regards.

Comment
Add comment · Show 2
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 drod7425 · Nov 11, 2013 at 03:37 PM 1
Share

Where are you setting your offset? You want an offset, but I can't see where you're applying it. All I can see is that you're setting the waypoint position to the player position.

avatar image pvpoodle · Nov 11, 2013 at 04:09 PM 0
Share

i was trying

waypoint.transform.position = Vector3(player.transform.x , player.transform.y + 20 , player.transform.z + 20);

1 Reply

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

Answer by pvpoodle · Nov 11, 2013 at 04:11 PM

i think i have it figured out now.

i was not using the "new" keyword , which was what was causing problems for me.

just for anyone else having the same kind of problems , the code im using now is

 waypoint.transform.position = new Vector3(player.transform.x , player.transform.y + 20 , player.transform.z + 20);
Comment
Add comment · Show 1 · 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 __RIPstER__ · May 10, 2018 at 04:31 AM 0
Share

I think has changed since 2013. The new code for those wondering that I'm using is`player.position = new Vector3(transform.position.x, transform.position.y - 0.66f, transform.position.z + 20);` Note if you want to use decimal values, you have to type the "f" in at the end of the value, because unity cant convert the double value to a float.

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

18 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 avatar image

Related Questions

Storing transforms from objects in Array 1 Answer

Place a object in front the camera in the coordinate 0 of Y axis 2 Answers

Trying to set up some GUI using planes and textures. Need help with dynamic changes. 0 Answers

Two gameobjects with the same transform 1 Answer

HealthBar for 5 Objects 3 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