playMaker

Author Topic: What actions for a simple sailing game ? Wind direction influences speed.  (Read 2360 times)

secondsight

  • Playmaker Newbie
  • *
  • Posts: 24
So, how to do wind for a simple sailing game ? Think of "Pirates!".

I only have the wind direction and strenght, my ship direction and speed.
I´m wrapping my brain around the whole day what actions to use and I have no idea where to start !

Some ideas ? Is it possible ?

Thanks in advance !

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

That is not going to be a simple task by any mean...

wind is a force so that's ok, you can use AddForce action, however it's the boat behavior against the water and how the sail will affect the boat to deduce where it should head and react to the wind force. That is going to be more problematic.

searching the web gave nothing worse looking at unfortunatly...

Bye,

 Jean

secondsight

  • Playmaker Newbie
  • *
  • Posts: 24
Thanks for the input !

Yes, searching the web did not help me either.

I was thinking something along the line of comparing both directions somehow, of the wind and the ship. When the directions are close, no windforce is added. If they are opposite (like 180 to 0) the maximum windforce is added.

But yeah... this seems to be a bigger problem that I have anticipated originally.

drakwon

  • Playmaker Newbie
  • *
  • Posts: 34
you are going to want to make an FSM that uses math to create your wind forces, you can animate or use random floats to simulate the chaotic nature of wind, then apply those forces to an object.

I could help you work on it, I was working on a pirate type sailing game myself.

Thore

  • Sr. Member
  • ****
  • Posts: 480
Couldn’t this take advantage of gravity, and use this as the wind. It uniformly moves objects into a certain direction, and interacts with velocity. As far as I know, the direction of gravity can also be changed, and you have the rigidbody parameters such as drag, mass and gravity scale to play with.

secondsight

  • Playmaker Newbie
  • *
  • Posts: 24
@Thore
This is a very intersting idea ! Haven´t thought about that yet.
But I guess it would collide with my current setup for floating objects. Will think about it and give it a try.

secondsight

  • Playmaker Newbie
  • *
  • Posts: 24
you are going to want to make an FSM that uses math to create your wind forces...

Thanks for offering help ! I might come back to this :)

Right now, the force itself is not the problem, but the wind direction. I want the ship to drift or turn away a little if the wind comes from the side, go faster if the wind is from behin and slow down if the direction is coming towards it.

Did you do anything like this in your project as well ?

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
A simple way is to get your direction, normalize it, and multiply that by your speed. The result is your final wind movement. This result should be applied to your ship by adding force or adding to the velocity...

If you move your ship using velocity, you must add the final wind movement using velocity. If you use add force, then you must do the same, because if you move with velocity and add wind as a force, your velocity will cancel out the force as velocity overwrites your physics movement...

This is a simple way to apply a wind force to your object...
« Last Edit: October 18, 2019, 10:41:41 AM by ransomink »