Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, rki), 390 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Tilting independent collision hull #471823
03/21/18 05:35
03/21/18 05:35
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Is there a way I can tilt a collision hull of a player model independently from the player model itself (without tilting the player model as well)?

I have a collision hull made for the player when it walks upright (using a "walk" animation), and it is the perfect size and dimensions for the player while it walks upright. The camera faces the player's back when it walks upright.

The player also has a "swim" animation, to which I tilted the player model forward, to give the appearance of the player swimming as if it is lying on its stomach in the air, and the camera faces the bottom of the player's feet.

I have it programmed in the game so that the player's "walk" animation is in effect when it is out of the water. When it jumps into the water, the "swim" animation gets executed making the player's body tilt forward, so that the camera is facing the bottom of the player's feet as it swims in the water, instead of facing its back like it did while it was walking upright.

When the player is walking upright, the collision hull is right where it needs to be. When the player jumps into the water, initiating the "swim" animation, the collision hull stays where its at while the player's body tilts forward, so that the collision hull is not lining up with the player's body anymore, like it did while it was walking upright. It more crosses the player's body like a cross.

Is there a way I can tilt the collision hull forward to be in line with the player's body as it swims, while keeping the player model and its animations the way they are without changing them? This is the code I have so far:

Code:
action player_action()
{
   ...

   ent_create(NULL, &my->x, actCameraCollider); // Creating camera
                                                //    collider for
                                                //    collision hull.

   ...

   vec_set(&my->max_x, vector(2, 23, 50.5)); // Setting collision                                   
   vec_set(&my->min_x, vector(-2, -23, 0));  //    hull dimensions

   ...

   while(1)
   {
      ...

      if((key_w == 1) || (key_s == 1) || (key_a == 1) || (key_d ==
          1))
      {
         ...

         ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
            // In "walk" animation, player is standing upright, and
            //    the collision hull fits player's "standing upright"
            //    pose perfectly.
      }

      ...

      if(my.status == playerInWater) 
      {
         ...

         my.ANIMATION += 0.4*distance; 
         ent_animate(me,"swim",my.ANIMATION,ANM_CYCLE); 
            // "swim" animation has player tilting forward in a  
            //    swimming pose, instead of standing up.

         &my.tilt -= 60; // Trying to tilt collision hull to go in
                         //    line with player's swimming body, but
                         //    this is not working.  It is not 
                         //    tilting an inch.

         ...
		
      }										  	
      wait(1);
   }
}



I tried doing this:

Code:
@my.tilt -= 40; // ...and various other numbers



...but the collision box is not tilting an inch. Any advice would be greatly appreciated on how to tilt the collision box independently from the player model itself. Thank you.

Last edited by Ruben; 03/22/18 03:41.
Re: Tilting independent collision hull [Re: Ruben] #471854
03/21/18 16:56
03/21/18 16:56
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I'd say use two independent entities. One for visuals and another one for collisions.


POTATO-MAN saves the day! - Random
Re: Tilting independent collision hull [Re: Kartoffel] #471864
03/22/18 05:34
03/22/18 05:34
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Never mind. I believe I found an easy solution to this.

I initially set the original "standing" collision hull measurements before the while loop. Including creating a var called "inTheWater = 0"; and also initially set "water_mode = 0", since player starts out on land.

In the while loop, I created 2 conditions, "if ((water_mode == 0) && (inTheWater == 1))", and "if (water_mode == 1)". In the "water_mode == 1" condition (meaning the player is in the water) I would set the new "swimming" collision hull dimensions, and change the inTheWater value to be 1. In the "water_mode == 0 && inTheWater == 1" condition, I set the collision hull all to 0's, and created a goto function call going back to the beginning of the function. Now it seems to work.


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