Announcement

Collapse
No announcement yet.

Relative Physics Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #91
    Interestingly I have the same problem as I am building the ship from scratch again to find some bugs.

    In my working code I have a custom PlayerInput class which does nothing related to the mouse.^^

    My Controller class passes the aMouseX and Y to the ship every tick.

    Code:
    Ship.SetInputs2(PlayerInput.aMouseX / 20, -PlayerInput.aMouseY / 20);
    You have to tweak the 20s of course.

    I'll post here when I found out whether there is an easier way and if the mouse input depends on other things, too.

    Comment


      #92
      Sorry, my last post was really short. I was in a hurry.

      To elaborate:

      The rotation in UDK is done differently than applying the mouse input directly as force/torque to a ship. The rotation (the direction the player should face) is calculated by mouse movement, gamepad and others. The Controller gets a rotation and passes it to the pawn (a human model, a vehicle, etc. Something the player can move).

      Usually we would be able to use this rotation. The problem is that the rotation does not care about roll. On top of that Pitch/Tilt is treated like an unloved stepchild, because only the camera and the weapon orientation need it.

      This is why I wrote my own function SetInputs2, belonging to the ship, that passes the mouse input from the Controller to the ship directly. The ship rotation in the level is then used to set the rotation of controller so the radar is correctly orientated as well. Somewhat of a hack, but it works well.

      If you are familiar with the basics of multiplayer programming in UDK you can use SetInputs2 to send the input accross the network. But this is another topic, consider this just a hint for later. ;-)

      So what needs to be done, to get this to work, like I am currently doing it?

      You need your own game mode class, preferably deriving it from UTGame or UTDeathMatch. This way you can make UDK use your own controller. Most advanced coders will have done that already.

      Now to concrete code:

      The ship, called SpaceShip

      Code:
      Class SpaceShip extends UTVehicle;
      
      var vector input_turn;
      
      ...
      
      // own InputSet function, currently not used
      simulated function SetInputs2(float Yawing, float Pitching, float Rolling)
      {
      	input_turn.X = Rolling; // roll
      	input_turn.Y = Pitching; // pitch / tilt
      	input_turn.Z = Yawing; // yaw
      }
      
      simulated function AirRaidKinematics(float DeltaTime)
      {
            ...
      		// Roll
      		AR_ForceRotationVectX *= input_turn.X;
      
      		// Pitch
      		AR_ForceRotationVectY *= input_turn.Y;
      
      		// Yaw
      		AR_ForceRotationVectZ *= input_turn.Z;
      
      		// Add them together to get final global rotation vector:
      		AR_ForceRotation = AR_ForceRotationVectX + AR_ForceRotationVectY + AR_ForceRotationVectZ;
      }
      
      ...
      The controller, MyControllerPlayer

      Code:
      MyControllerPlayer extends UTPlayerController;
      
      // PlayerTick is only called if the PlayerController has a PlayerInput object. Therefore we need a dummy one
      event PlayerTick (float DeltaTime)
      {
             local SpaceShip ship;
      
      	super.PlayerTick(DeltaTime);
      
            ship = SpaceShip(pawn);
      
           // we are controlling a ship
           if(ship != none)
           {
                  Ship.SetInputs2(PlayerInput.aMouseX / 20, -PlayerInput.aMouseY / 20, 0);
                  // instead of 0 pass the value of the buttons you want use for roll
           }
      }
      
      // set the rotation of controller to that of the ship
      function ProcessViewRotation( float DeltaTime, out Rotator out_ViewRotation, Rotator DeltaRot )
      {
      	local SpaceShip Ship;
      	local Vector vec; // dummy var to satisfy GetSocketWorldLocation...
      
      	Ship = SpaceShip(Pawn);
      
      	if(Ship == none)
      		super.ProcessViewRotation( DeltaTime, out_ViewRotation, DeltaRot );
      	else
      	{
      		//get the location and rotation of the socket
      		Pawn.Mesh.GetSocketWorldLocationAndRotation(Ship.Seats[0].CameraTag, vec, out_ViewRotation);
      	}
      }
      
      DefaultProperties
      {
      }
      Code:
      // just a dummy, can serve as a central palce for exec functions
      class MyPlayerInput extends UTPlayerInput within MyControllerPlayer;
      
      exec function do Sth()
      {
      
      }
      
      DefaultProperties
      {
      }
      That's it, happy coding guys.

      ----------------------------------------------

      Important news:

      To get gravity for your plane/spaceship is really simple. I just figured it out. Extend from UTVehicle instead of UTAirVehicle.
      Then it won't use PHYS_FYLING anymore. Keep in mind that your vehicle must have a strong enough climbing force to get off the ground if you have the default gravity of -512.

      This seems somewhat strange, but makes sense as UTAirVehicle is supposed to implement a flying vehicle for a FPS, not a flight simulator.

      In conclusion we got a car which can fly. And has no wheels. ;-)
      Attached Files

      Comment


        #93
        thats strange you have to send it from the controller, but if that works, awesome
        thanks
        i always did extend UTVehicle, must be why some of your posts didnt make sence, or didnt apply to my spaceship. i dont need to do anything with gravity too, its like its in 0G anyway.

        Comment


          #94
          Originally posted by Hiredicespecter View Post
          Sorry, my last post was really short. I was in a hurry.

          To elaborate:

          The rotation in UDK is done differently than applying the mouse input directly as force/torque to a ship. The rotation (the direction the player should face) is calculated by mouse movement, gamepad and others. The Controller gets a rotation and passes it to the pawn (a human model, a vehicle, etc. Something the player can move).

          Usually we would be able to use this rotation. The problem is that the rotation does not care about roll. On top of that Pitch/Tilt is treated like an unloved stepchild, because only the camera and the weapon orientation need it.

          This is why I wrote my own function SetInputs2, belonging to the ship, that passes the mouse input from the Controller to the ship directly. The ship rotation in the level is then used to set the rotation of controller so the radar is correctly orientated as well. Somewhat of a hack, but it works well.

          If you are familiar with the basics of multiplayer programming in UDK you can use SetInputs2 to send the input accross the network. But this is another topic, consider this just a hint for later. ;-)

          So what needs to be done, to get this to work, like I am currently doing it?

          You need your own game mode class, preferably deriving it from UTGame or UTDeathMatch. This way you can make UDK use your own controller. Most advanced coders will have done that already.

          Now to concrete code:

          The ship, called SpaceShip

          Code:
          Class SpaceShip extends UTVehicle;
          
          var vector input_turn;
          
          ...
          
          // own InputSet function, currently not used
          simulated function SetInputs2(float Yawing, float Pitching, float Rolling)
          {
          	input_turn.X = Rolling; // roll
          	input_turn.Y = Pitching; // pitch / tilt
          	input_turn.Z = Yawing; // yaw
          }
          
          simulated function AirRaidKinematics(float DeltaTime)
          {
                ...
          		// Roll
          		AR_ForceRotationVectX *= input_turn.X;
          
          		// Pitch
          		AR_ForceRotationVectY *= input_turn.Y;
          
          		// Yaw
          		AR_ForceRotationVectZ *= input_turn.Z;
          
          		// Add them together to get final global rotation vector:
          		AR_ForceRotation = AR_ForceRotationVectX + AR_ForceRotationVectY + AR_ForceRotationVectZ;
          }
          
          ...
          The controller, MyControllerPlayer

          Code:
          MyControllerPlayer extends UTPlayerController;
          
          // PlayerTick is only called if the PlayerController has a PlayerInput object. Therefore we need a dummy one
          event PlayerTick (float DeltaTime)
          {
                 local SpaceShip ship;
          
          	super.PlayerTick(DeltaTime);
          
                ship = SpaceShip(pawn);
          
               // we are controlling a ship
               if(ship != null)
               {
                      Ship.SetInputs2(PlayerInput.aMouseX / 20, -PlayerInput.aMouseY / 20, 0);
                      // instead of 0 pass the value of the buttons you want use for roll
               }
          }
          
          // set the rotation of controller to that of the ship
          function ProcessViewRotation( float DeltaTime, out Rotator out_ViewRotation, Rotator DeltaRot )
          {
          	local SpaceShip Ship;
          	local Vector vec; // dummy var to satisfy GetSocketWorldLocation...
          
          	Ship = SpaceShip(Pawn);
          
          	if(Ship == none)
          		super.ProcessViewRotation( DeltaTime, out_ViewRotation, DeltaRot );
          	else
          	{
          		//get the location and rotation of the socket
          		Pawn.Mesh.GetSocketWorldLocationAndRotation(Ship.Seats[0].CameraTag, vec, out_ViewRotation);
          	}
          }
          
          DefaultProperties
          {
          }
          Code:
          // just a dummy, can serve as a central palce for exec functions
          class MyPlayerInput extends UTPlayerInput within MyControllerPlayer;
          
          exec function do Sth()
          {
          
          }
          
          DefaultProperties
          {
          }
          That's it, happy coding guys.

          ----------------------------------------------

          Important news:

          To get gravity for your plane/spaceship is really simple. I just figured it out. Extend from UTVehicle instead of UTAirVehicle.
          Then it won't use PHYS_FYLING anymore. Keep in mind that your vehicle must have a strong enough climbing force to get off the ground if you have the default gravity of -512.

          This seems somewhat strange, but makes sense as UTAirVehicle is supposed to implement a flying vehicle for a FPS, not a flight simulator.

          In conclusion we got a car which can fly. And has no wheels. ;-)

          I know copy-paste is bad, and I think I already know the answer, but If I copy-pasted what you have here on this page, It still needs additional code (other pages back) in order to rotate correctly, right?

          Comment


            #95
            EDIT Oops double post

            Comment


              #96
              Originally posted by 1Lt Coagulator View Post
              I know copy-paste is bad, and I think I already know the answer, but If I copy-pasted what you have here on this page, It still needs additional code (other pages back) in order to rotate correctly, right?
              Somewhat. The class names need to be adjusted in some cases and you have to merge the code for the ship. Quite close to copy and paste, but still needs a basic understanding of what you are doing.

              Comment


                #97
                Alien walk on surface
                Hi All,

                When aliens are walking on the surface,their legs going to down .....


                what the problem????


                kindly help me.....

                Comment


                  #98
                  The code that belongs to the class AR_Aircraft previously posted here. I renamed it to SpaceShip in my post, because I felt it would be a better name.

                  Comment


                    #99
                    Alien walk on surface
                    Hi All,

                    When aliens are walking on the surface,their legs going to down .....


                    what the problem????


                    kindly help me.....

                    Comment


                      Alien walk on surface
                      Hi All,

                      When aliens are walking on the surface,their legs going to down .....


                      what the problem????


                      kindly help me.....

                      Comment


                        Originally posted by marineuac View Post
                        but i could never get pitch and yaw to work via the mouse!
                        I'll look into this during this weekend. My guess so far is that playerTick of your controller is not called, because you don't have a custom PlayerInput class (it can be empty). Have you verified it gets called by doing logging:
                        Code:
                        `log("Controller got called!")
                        ?

                        Comment


                          @Hiredicespecter: You don't need custom PlayerInput - exec functions will be called anyway and this have nothing to do with PlayerTick

                          @marineuac: Put some log in SetInputs2 function...

                          Comment


                            Alien walk on surface
                            Hi All,

                            When aliens are walking on the surface,their legs going to down .....


                            what the problem????


                            kindly help me.....

                            Comment


                              Originally posted by VendorX View Post
                              @Hiredicespecter: You don't need custom PlayerInput - exec functions will be called anyway and this have nothing to do with PlayerTick
                              This is not about exec functions. Which the posted code does not use by the way.

                              For playerTick not being called without a custom playerInput: see http://wiki.beyondunreal.com/UE3:UTP...%29#PlayerTick


                              After reading that again, I guess if your controller extends from UTPlayerController it already has a playerInput. Or I needed it for multiplayer to work for some other custom input code. I didn't conducted tests as I needed a custom playerInput anyway.

                              @marineuac: Do you use a custom playerInput class?

                              Comment


                                Alien walk on surface
                                Hi All,

                                When aliens are walking on the surface,their legs going to down .....


                                what the problem????


                                kindly help me.....

                                Comment

                                Working...
                                X