Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Game Development › Unity / UDK / GameStudio / CryEngine Development › [Unity Scripts]Sailing Ship Controls(Js)

[Unity Scripts]Sailing Ship Controls(Js)

Posts 1–4 of 4 · Page 1 of 1
OBrozz
OBrozz
[Unity Scripts]Sailing Ship Controls(Js)
Code:
var speed = 1.0;
var acceleration = 1.0;
var maxspeed = 2.0;
var minspeed = -0.25;
var heading = 0.0;
var rudder = 0.0;
var rudderDelta = 2.0;
var maxRudder = 6.0;
var bob = 0.1;
var bobFrequency = 0.2;

private var elapsed = 0.0;
private var seaLevel = 0.0;
private var rudderControl;
private var rudderAngle = 0.0;

function signedSqrt( x ){
   var r = Mathf.Sqrt(Mathf.Abs( x ));
   if( x < 0 ){
      return -r;
   } else {
      return r;
   }
}

function Update () {
   // Bobbing
   elapsed += Time.deltaTime;
   transform.position.y = seaLevel + bob * Mathf.Sin(elapsed * bobFrequency * (Mathf.PI * 2));
   
   // Steering
   rudder += Input.GetAxis("Horizontal") * rudderDelta * Time.deltaTime;
   if( rudder > maxRudder ){
      rudder = maxRudder;
   } else if ( rudder < -maxRudder ){
      rudder = -maxRudder;
   }
   heading = (heading + rudder * Time.deltaTime * signedSqrt(speed)) % 360;
   // transform****tate(0, rudder * Time.deltaTime, 0);
   transform.eulerAngles.y = heading;
   transform.eulerAngles.z = -rudder;
   
   if( rudderControl ){
      rudderAngle = ((-60 * rudder)/maxRudder + heading) % 360;
      //rudderControl.transform.localEulerAngles.y = (70 * rudderAngle) % 360;
      rudderControl.transform.eulerAngles = Vector3(0, rudderAngle, 0);
   }
   
   // Sail
   speed += Input.GetAxis("Vertical") * acceleration * Time.deltaTime;
   if( speed > maxspeed ){
      speed = maxspeed;
   } else if ( speed < minspeed ){
      speed = minspeed;
   }
   
   transform.Translate(0, 0, speed * Time.deltaTime);
}

function Awake (){
   seaLevel = transform.position.y;
   rudderControl = GameObject.Find("rudderControl");
}
#1 · 15y ago
XX_Kivata_XX
XX_Kivata_XX
thank you for a code /?
#2 · 15y ago
Terell.
Terell.
Quote Originally Posted by XX_Kivata_XX View Post
thank you for a code /?
Its helpful for when you create a game ..
#3 · 15y ago
ST
Stephen
You need to post credits. :3
#4 · 15y ago
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

  • [Unity Scripts]Simple AI Behavioral scriptBy OBrozz in Unity / UDK / GameStudio / CryEngine Development
    6Last post 15y ago
  • Habbohotel ScriptsBy h0ang in General Game Hacking
    8Last post 19y ago
  • CBS Controls StarTrekBy Dave84311 in SCI-FI
    5Last post 20y ago
  • [TUTORIAL]How to control an airplane :p and ofcourse insert itBy System79 in WarRock - International Hacks
    8Last post 20y ago

Tags for this Thread

None