Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, howardR), 646 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Underwater Movement #453003
07/04/15 07:49
07/04/15 07:49
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
My goal is to make it to where if the player goes underwater, the player should be able to move in whatever direction the camera is facing. I have the program set up now that if the player jumps into water (using a region called "water"), I can make certain things happen like changing fog_color to equal 2 (creating a blue underwater fog).

When the player is above water on ground in my program, the player can only move front, back, right, and left, in whatever direction the camera is facing along those dimensions. When the player jumps into water, I would like the player to move in whatever direction the camera is facing, even if that means up, down, diagonal up or down, along with front, back, right, and left. I take it this involves working with the z variable.

This is the code I have so far for this:

Code:
action player_code()
{
   ...

   if(fog_color == 0)
   {
      move_vec.x = key_w - key_s;
      move_vec.y = key_a - key_d;
   }
   if(fog_color == 2)
   {
      move_vec.x = key_w - key_s;
      move_vec.y = key_a - key_d;
   }

   ...
}



When the player is on ground (fog_color = 0), the movement works just fine along the x and y planes.

When the player is underwater (fog_color = 2), I would like the player's movement to go any direction that the camera is facing. So for example, if the player's camera is facing diagonal up, and the player holds down the w key, I would like the player to swim diagonal up. If the player were to press and hold the s key while its camera is facing diagonal up, I would like the player to swim in reverse diagonal down.

I take it I would have to manipulate the move_vec.z , my.pan, and camera.pan somehow under the "if(fog_color == 2)" condition above. I have tried my own methods of manipulating these values, but nothing has worked so far.

Anyone have an idea on how to make this kind of underwater movement that I just described possible?

Re: Underwater Movement [Re: Ruben] #453004
07/04/15 08:55
07/04/15 08:55
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Either adapt the player's orientation to the camera's pan (and tilt) and use a relative speed vector (first speed argument in c_move) or use vec_rotate with camera.pan and as an absolute speed vector.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Underwater Movement [Re: Superku] #453010
07/05/15 08:14
07/05/15 08:14
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Superku. I set the player's pan and tilt equal to the camera's pan and tilt, and now the underwater movement works perfectly. :-)


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1