Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by overlordyigit1 · May 28, 2016 at 06:38 PM · aiorbitshipboat

object look center when orbiting with near sides

hello, Im new to unity and ı trying to make pirate ship ai. that attack player with orbiting but how i can make the enemy ship looking player with sides (broadside).like this; alt text the script i used :

         GameObject cube;
         public Transform center;
         public Vector3 axis = Vector3.up;
         public Vector3 desiredPosition;
         public float radius = 2.0f;
         public float radiusSpeed = 0.5f;
         public float rotationSpeed = 80.0f;
 
         void Start () {
             cube = GameObject.FindWithTag("Cube");
             center = cube.transform;
             transform.position = (transform.position - center.position).normalized * radius + center.position;
             radius = 2.0f;
         }
 
         void Update () {
             transform.RotateAround (center.position, axis, rotationSpeed * Time.deltaTime);
             desiredPosition = (transform.position - center.position).normalized * radius + center.position;
             transform.position = Vector3.MoveTowards(transform.position, desiredPosition, Time.deltaTime * radiusSpeed);
         }
     }

unitycomm.png (37.0 kB)
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 vittu1994 · May 28, 2016 at 08:10 PM 0
Share

You want the ship to face forward while traveling around the player in orbit? (like in the right picture) and have only the sides of the ship face the player?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by vittu1994 · May 28, 2016 at 08:16 PM

If i understand your question correctly and assuming you want the ship to act like in the right picture. You can create a empty gameobject inside the ship as a child object that will be set a bit more forward then the ship. Then you access the transform of this empty gameobject in your ship script and use this in its update:

 transform.LookAt(yourEmptyObject);

Every frame the ship should look at this object and having its forward direction constantly facing it.

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 Mmmpies · May 28, 2016 at 08:33 PM 0
Share

I think that would just sail off into the sunset. How about having an object that's at right angles to the ship (so pointing to where the ship it's circling is). Get that to look at the ship being circled but propel the ship forward along it's own transform.

You might have to make the look at object a parent rather than a child but it's Saturday night on a bank holiday weekend (we get $$anonymous$$onday off) in the U$$anonymous$$ so I've already hit the wine and my logic circuits are getting a bit fuzzy! :D

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Salingship ai with addforce movement 0 Answers

Problem with a ship controller script 1 Answer

Smooth Rotation Quaternion Lerp? 1 Answer

Enemy watches player and shoots but bullets will not project 0 Answers

Trouble making jumping spider enemies 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