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
-1
Question by Giovi99Menga · Dec 17, 2013 at 04:44 PM · waterboatderp

SailBoatGame-SailSystemScript

Hi, i'm italian and my english isn't very good but i hope you can help me: I'm making a Sail Game and i want that when my ship is between 30 an 90 degrees my beautiful mainsail is shown; i try to use this script:

function Update () {

 if (((transform.eulerAngles == Vector3(0,30,0)) && (transform.eulerAngles == Vector3 (0,90,0)))
 {
     RBSx.renderer.active = true;
 }

PLEASE HELP ME!!!

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 Kiloblargh · Dec 17, 2013 at 05:09 PM

Well, your English is better than your maths. Your code will set the renderer active if and only if the eulerAngles are exactly (0,30,0) AND exactly (0,90,0) at the same time, which is not a common occurrence.

Also, I can see sailboats out on the bay every day here and I have never noticed their main sails blinking out of existence every time they turn downwind, so you should probably rethink your whole approach anyway.

What you want is if ((a > b) && (a < c)).

You need to figure out your wind direction- which may not be the world Z axis, and calculate angles relative to that. Here's a minimal set of things you're going to have to take into account to control the boat's behavior in a realistic way-

 var rudder : float; // steering, -1 to 1, causes the boat to rotate on Y axis
 var boom : float; // local y rotation of the boom relative to the boat
 var jib : float; // how much the rope to the front sail is let out

 var windSpeed : float;
 var boatSpeed : float;
 var windDir : Vector2; 
 var heading : Vector2;
 var attack : float; // angle between windDir and heading
 var tilt : float; // boat's z axis rotation- depends on boom, jib, windSpeed, and attack

 function Tack(){} //flip sail direction when boat crosses wind direction upwind

 function Jibe(){} //flip sail direction when boat crosses wind direction downwind

 





Comment
Add comment · Show 4 · 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 Giovi99Menga · Dec 17, 2013 at 05:46 PM 0
Share

thank you very much but the string : if (((transform.eulerAngles == Vector3(0,30,0)) && (transform.eulerAngles == Vector3 (0,90,0))) doesn't work

avatar image Kiloblargh · Dec 17, 2013 at 05:52 PM 0
Share

Of course it doesn't work, because it's wrong. It is equivalent to if (false).

Isn't that why you posted this question in the first place?

avatar image Giovi99Menga · Dec 18, 2013 at 03:31 PM 0
Share

i explained the problem wrong; I need some helps to use the just script because $$anonymous$$e didn't work well

avatar image Giovi99Menga · Dec 18, 2013 at 04:02 PM 0
Share

anyway you help me so much whit your script, i'm trying to make all the script

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

17 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

Related Questions

Object buoyancy in water on different water levels? 1 Answer

Floating boat 1 Answer

How do I cull water in my boat without setting render queue to transparent? 0 Answers

Buoyancy Toolkit, how do you move the object 0 Answers

Having trouble with player boat movement with buoyancy pack 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