Jump to content
Sign in to follow this  
six_ten

Mathematics help and custom AnimationSource controller from windDir

Recommended Posts

I have a script that pushes my sloop (sailing vessel) in the wind; the engine works but its power is reduced so most thrust must come from wind. If you sail into the wind, you can move forward slowly, a couple of km/hr. If you sail with the wind at your back or sides, you can move up to 20 km/hr or so. This works now. To make it more realistic I want to do the following:

1. Get the wind direction relative to the ship direction and set the angle of the yards, boom and gaff (the parts that hold the sails onto the mast). For this I think I need a custom AnimationSource controller, right? At the moment the angle of the boom, gaff and yards is set by the rudder just to see how it looks. I would like to have this independently controlled by the captain, but for the sake of new players and AI it seems best to automatically set the best angle. I don't know how to do the math to convert windDir and shipDir to the angle of difference between them. One the math is done, how do I send that to an animationsource so that it will rotate them?

2. Taking the result of the above, the angle of difference between wind and ship, multiply (?) that by the square yardage of sails remaining (enemies can shoot and destroy rigging and sails) and use that number to set the velocity of the ship. Currently you can shoot out the Boom and Gaff, which hold the MainSail. Is the correct expression "isDestroyed" when they are hidden and replaced with damaged versions? I want to assign a value for each sail, based on number of square yards, and when one is destroyed, deduct that amount from a multiplier that feeds into the ship velocity.

1794 Steel diagram

http://i.imgur.com/8MvjAzO.jpg

Edited by Six_Ten

Share this post


Link to post
Share on other sites

Thanks.

In order to understand how this all works I'm trying to make a weathervane, a simple arrow that points to the direction the wind blows. With windDir I can get the wind direction, but how do I tell the arrow to point that direction? There's no stock animationsource for windDir, so do I need to run it from a script? If so, how does the anim know to use windDir to set its direction?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×