Concern about new update regarding new wave machanic API

  • Hi!


    With upcoming update very close and with "The next update will definitely introduce true ocean waves (including new boat behaviour of course)" i wonder if API is ready to handle the following scenario:

    I use a plugin to make a boat to follow automatic route (Ferry Travel). This internally is handled by moving (teleport) the boat along some predefined route (points defined by x,z coordinate). For y axis (water level) is more ore less around 90 (depend on boat type - rowboat, sailboat, have different values).


    Now questions:

    - With new wave mechanic where water in a some point x,z will be dynamic (other than static 90) how i will determine correct height via API to know where to teleport a boat in a new point at surface of water?


    So wee need some sort of API to can calculate real height of water (with wave corrections) in some point x,z.

    Moreover this is not enough, because different boat size sink in water different depth (rowboat versus sailboat) so we need a real API function to obtain "correct" Z value so vehicle (rowboat,sailboat,etc.) can be teleported on valid,"naturally" point x,z at surface of water.


    Now i move vehicle with some code like:



    Current movement of rowboat is on flat water level. So first align vehicle to target and latter move. But with real wave ... i see this like more steps:

    - First align direction of vehicle to desired direction

    - Second move vehicle in new location

    - Last step normalize rotation (keeping aligned direction) to naturally fit current wave (this i think need to be addressed via API too!)


    red51 i hope you will take in account this API additions (if is not yet some method who can achieve this scope) for new release.


    Thx in advance!

  • Hey, that's a good point! Currently the waves are not taken into account, so setPosition() would still work, but it would cause the boat to temporarily hover above water or submerge. The API will provide a method to calculate the wave height at a specific location, but this will only help if you call vehicle.setPosition() very often (providing the final water position which also takes the waves into account)...


    We could change the setPosition() method to take waves into account automatically, but I'm not sure if that would be a good idea... right now this method allows you to set an arbitrary position (you can even set a position on land or in the air). Maybe a new "setPositionOnWater()" method would be better in this case? :thinking:


    Or maybe we change setPosition() to teleport a vehicle instantly, and add a new "moveTo()" method (which optionally takes waves into account)? This could be a cleaner solution... IMO the current behaviour isn't very intuitive anyway (I'd expect a vehicle to move to a new position instantly when calling setPosition())... the "moveTo" method could then get a few parameters, e.g. to determine if the boat should automatically adapt to waves or if a player should still be able to take control over the boat. Maybe that would be the best solution? ^^

  • Hey, that's a good point! Currently the waves are not taken into account, so setPosition() would still work, but it would cause the boat to temporarily hover above water or submerge. The API will provide a method to calculate the wave height at a specific location, but this will only help if you call vehicle.setPosition() very often (providing the final water position which also takes the waves into account)...


    We could change the setPosition() method to take waves into account automatically, but I'm not sure if that would be a good idea... right now this method allows you to set an arbitrary position (you can even set a position on land or in the air). Maybe a new "setPositionOnWater()" method would be better in this case? :thinking:


    Or maybe we change setPosition() to teleport a vehicle instantly, and add a new "moveTo()" method (which optionally takes waves into account)? This could be a cleaner solution... IMO the current behaviour isn't very intuitive anyway (I'd expect a vehicle to move to a new position instantly when calling setPosition())... the "moveTo" method could then get a few parameters, e.g. to determine if the boat should automatically adapt to waves or if a player should still be able to take control over the boat. Maybe that would be the best solution? ^^


    I like vehicle.setPositionOnWater(x,z) if that take in account wave position.

    But vehicle.moveOnWaterTo(x,z,adaptWave==true) with additional parameters don't sound bad. It can work for example to do last step to "normalize" position of boat with wave.

  • After taking a closer look at this, I think I'd prefer a new moveTo()-Method, considering that the "Vehicle" class will represent more than just boats in the future. The moveTo()-Method will then get a universal "adaptToSurface" parameter, which not only adapts the boat/vehicle to water/waves, but also to terrain (in case you're moving a boat/vehicle on land). Unlike setPosition(), it will maintain a constant speed (which can be changed via parameter). It will also update the vehicle pitch and roll (but not the yaw) automatically.


    This should make it possible to create quite realistic boat rides :)

  • Nice.


    But if understand that speed parameter is a server config parameter? It will affect speed of all vehicles? Ideally for this use cases i really love to can modify speed without affecting all vehicle normal behavior. Maybe method can get a more parameter like speedFactor, beside adaptToSurface? This way we can move for example twice as fast a vehicle (boat in this case) with a factor 2 or at half speed with a factor 0.5 compared with standard speed. This will be really wonderful! For example in my current implementation i don't move (teleport) boat at same speed along route, i have 3 phases:

    - acceleration (0-25% of route) where boat start moving more quick

    - cruise (25%-75%) where boat move at constant maximum speed

    - deceleration (75%-100%) where boat start to slow speed till stop

    A variable speed factor for moveTo() method it will help a lot this type of use case!

    And another question MoveTo will have only (x,z) coordinates or (x,y,z)? I suppose is first case and for y adapt by water/terrain?


    Thx

  • No, sorry for the confusion: I was actually referring to a speed parameter for the moveTo() method. This is what the method header will look like: public void moveTo(Vector3f position, float speed, boolean adaptToSurface)


    But the speed parameter is not related to the max speed of the vehicle itself. For instance, if you set a speed parameter of "10", it will work the same for all vehicles (it doesn't matter if you call this for a rowboat or a rib, they will simply move with a speed of 10) :)


    And another question MoveTo will have only (x,z) coordinates or (x,y,z)? I suppose is first case and for y adapt by water/terrain?

    You can provide an x, y and z coordinate. If the adaptToSurface parameter is true, the game will try to adapt the vehicle to the nearest surface. It wouldn't be sufficient to only have an x,z coordinate, because it's still possible to have water/terrain at different elevations (e.g the ocean, water in caves, maybe someone builds a floating island with a lake on it etc) ^^


    In your case, if you only want to enable traveling over the ocean, it would be fine to just provide 90 as y coordinate (no need to take waves into account etc).

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!