Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Help required from a developer!

A topic by Hi-Tech Developerz created Aug 06, 2022 Views: 361 Replies: 4
Viewing posts 1 to 4

So I am making a multiplayer online game in 3d on pirates. I have set up my ship, player, and character controller. I have also made a steerer script that switches the view when I press f to steer and disables the player movement.

Here is the question!

How do I make my ship that it always moves in the same direction it is facing, even when I am not steering? Also, if I start to steer my ship, I want it to be like if I change my direction (using the arrow keys), the force that moves the ship forward also changes and applies to the direction in which the ship is facing.

I have tried A LOT and could have just made the ship rotate in the direction I want, but I can’t make it move in that direction. If you are a developer, please help me in this situation. Your help will be highly appreciated!

I am not sure what technologies you are using or what you have already tried, but all you should need to do is apply a force* along the ship object's forward axis, i.e. the vector that corresponds to the ship's facing.  So for example, if the ship's positive Z axis points in the direction of travel, you would direct its movement along the positive Z axis (relative to the ship, not the world space).  Meanwhile, steering would just rotate the ship along its vertical axis without applying a directional force.  This would mean that regardless of how the ship is rotated, it will always continue moving along its own forward axis.

I am not an expert in nautical physics, so you may be trying to do something more complicated, but this should handle the basic case.

* Substitute translation, acceleration, etc. for whatever method you're using to calculate movement.

Thanks, it helped me with the problem! But now my player is not staying still on the ground. And also when I move, it kind of lags and does show a snappy movement, even though I am using a fixed update.

It sounds like you need to apply gravity to the ship and/or increase its mass.  Or, if the ship never needs to move up and down at all, you could just reset its Y position every frame.

As for jittery movement, if you are applying a force or some other physics function, you should do it in FixedUpdate.  If you are applying a regular translation or rotation or doing anything else, you should do it in Update.

I am using unity

Moderator moved this topic to General Development