Announcement

Collapse
No announcement yet.

Relative Physics Problem

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

    #76
    For the mouse: I haven't changed my inis for the mouse at all.

    The bindings doing the magic are in UDKInput.ini, section [Engine.PlayerInput]:
    Bindings=(Name="MouseX",Command="Count bXAxis | Axis aMouseX")
    Bindings=(Name="MouseY",Command="Count bYAxis | Axis aMouseY")

    I should be honest about this, I have never accessed the mouse in singleplayer only coding, went straight for multiplayer. That's why I am not sure if it works the way you try it to do. Logging is the way to go to figure this out.

    For the additional buttons:
    Are you aiming for single or multiplayer?

    If you are fine with a singleplayer game it is less work to do, but getting the multiplayer working later on is a very big load of work.

    Why am I asking whether multiplayer or singleplayer?

    Multiplayer coding makes things at least 4 times more difficult, especially for a beginner, since you have to take care to syncronize values and reduce bandwith usage.

    So what will it be? MP or SP? Beware that I won't help you with multiplayer issuse unrelated with the input for ship, because this a complex topic on its on. Although I might provide links to some tutorials. ;-)

    Comment


      #77
      Hey man, sorry for the long reply, just got back from work My project is solely a single-player game, the multiplayer aspects would definately be a bit too much for me at the moment, it is something ala-Frontier Elite/Freelancer for my final project at uni, my main project goals at the bare minimum (to stay realistic in my short time frame through my final year) are reasonably tight flying/pewpew mechanics and hopefully some docking/trading/repair between a couple of stations.

      If things go much better than expected then within that, during my games level(s), for progression I want to have some scripted events that have the player having to do a trade run or two, fight enemies(fighters/bomber class), destroy a capital ship by taking out its engines (or something to that effect) to make it exciting for my final showcase. Once uni is out the way in June/July I'll probably then be looking to expand greatly upon the game with good narrative and story to really hammer out the exploration aspect of my game.

      Thanks for the reply btw, your space shooter WIP looks incredible! I'm also pretty gutted tbh as you seem to be achieving what I've been dreaming of making for so long haha, your work is really ******* good.

      Comment


        #78
        Thanks. If you have any feedback, comment or suggestion feel free to let me know. Not here, but in my Work in Progress Thread linked to in my signature, since this not the place to discuss my game. ;-)

        Please PM me when you have something to show on your project's progress. I am always curious what developer's of space games do.

        Comment


          #79
          Since I want to code a plane like vehicle within the next few weeks, I had a look at how gravity for flying vehicles works in UDK for starters.

          First of all, why is the space ship, whose code I posted previously, not affected by gravity?

          Because it is using PHYS_FLYING while being driven. Objects in the physic state PHYS_FLYING are no affected by gravity.
          If you exit the space ship, its physic state changes to PHYS_FALLING, in which the ship is affected by gravity and CustomGravityScaling.

          For a plane to be affected by gravity, you could try to use PHYS_FALLING all the time, but this would involve some heavy modification of the vehicle code or might be even impossible without access to native code.
          And since PHYS_FLYING is intended for flying vehicles it is better to stick with it and just add add gravity manually while the space ship/plane is being driven.

          To get the gravity of the gravityVolume the vehicle is currently into (or the world's gravity if it isn't within one):

          Code:
           
          if(bDriving)
          {
              AR_ForceApplication.Z += self.PhysicsVolume.GetGravityZ() * CustomGravityScaling;
          }
          By the way, this behavior makes sense for a game like UT where you wouldn't want something like a plane which needs gravity, lift, drag and thrust. UT just wants some choppers and hovering vehicles.
          This would cover gravity, thrust (the force of the engine) is already covered. I have found the related formulars at wikipedia, but I haven't had the time to test them in UDK yet.

          This side provides an easy explanation of the forces affecting a plane: http://www.aviastar.org/theory/basic...ght/index.html

          Edit

          The calculation of gravity that I provided above is wrong for at least two reasons. First, it doesn't consider the vehicle's mass. Just remember what we all hopefully learned in school: F = m * g
          g = self.PhysicsVolume.GetGravityZ()
          m = self.Mesh.BodyInstance.GetBodyMass()

          Second, there is no need to multiply with CustomGravityScaling, it is already included in GetGravityZ().

          I have included the 0.01, because the resulting gravity was too strong and I assume some constant factor is used natively as well. Maybe you have to experiment with that factor.

          Code:
          if(bDriving)
          {
              AR_ForceApplication.Z += self.PhysicsVolume.GetGravityZ() * self.Mesh.BodyInstance.GetBodyMass() * 0.01;
          }
          I ll post this in an extra post so that the subscribers to this will get a notice of this too.

          Comment


            #80
            Thank you all for a great thread, I've learned a ton reading and experimenting based on the various responses over the past couple months. I quickly got something up and running at first, for a non scriptor, I hope that says something. The above code that Hiredicespecter included for more realistic movement really helped me out a lot. I did have one question though. I'm using an Xbox controller for all of my movement and the controls finally feel right, except that I'd like to bind acceleration to say the left trigger so I can slow down and speed up while leaving Pitch and Roll as they are. How would I go about doing this?

            As a side note, I've been experimenting with UTSkel_Controls for the flaps and rudders and pretty close to getting something that looks halfway decent, though I need to research more on linking these constraints directly to the controller values to respond faster when turning.

            Thanks in advance, great community.

            Comment


              #81
              For the xbox-controller issue: the key bindings are handeld in DefaultInput.ini. This file is responsible for assigning any kind fo action to keys. A general introduction can be found here: http://udn.epicgames.com/Three/KeyBinds.html
              For the xbox specific binds search for the line that starts with .Bindings=(Name="XboxTypeS_LeftShoulder"

              I can't help you with UTSekl_Controls, since I haven't used them so far.

              Because of exams and moving, i haven't had time to implement a plane with air lift and stall. This will take some more time.

              Feel free to post any code that can simulate air lift and stall, if you get it working.

              Comment


                #82
                Bugf ix for gravity calculation

                The calculation of gravity that I provided some pages ago is wrong for at least two reasons. First, it doesn't consider the vehicle's mass. Just remember what we all hopefully learned in school: F = m * g
                g = self.PhysicsVolume.GetGravityZ()
                m = self.Mesh.BodyInstance.GetBodyMass()

                Second, there is no need to multiply with CustomGravityScaling, it is already included in GetGravityZ().

                I have included the 0.01 factor, because the resulting gravity was too strong and I assume some constant factor is used natively as well. Maybe you have to experiment with that factor.

                New:
                Code:
                if(bDriving)
                {
                    AR_ForceApplication.Z += self.PhysicsVolume.GetGravityZ() * self.Mesh.BodyInstance.GetBodyMass() * 0.01;
                }
                Old:
                Code:
                if(bDriving)
                {
                    AR_ForceApplication.Z += self.PhysicsVolume.GetGravityZ() * CustomGravityScaling;
                }
                I have edited the original post to refelcted this.

                Comment


                  #83
                  I have been playing around with this stuff and I have come across one problem. My vehicle does not slow down, or stop spinning, once I have applied torque or force.

                  Is there any kind of friction functionality present in the existing code? I haven't been able to find it.

                  Comment


                    #84
                    The 'air friction' your are looking for is called damping. It is NOT set in the script, it is set in the vehicles PhysicalMaterial and called AngularDamping (for turning) and linear damping (for movement).
                    I guess you have not assigned any to your vehicle. It needs to PhysMats btw. One when its driving and one when it's not driven. Have a look at the cicada content code.

                    Comment


                      #85
                      ive been experimenting with a solution for that but nothing concrete yet.
                      you can work out the rotation rate and add an opposing rotation force, but its jerky and i would like it to self level.
                      tried adding a SimHelicopter object, this makes it self level sometimes and others it will spin wildly out of controll.
                      still working on it now and then so ill have a solution sooner or later.
                      feel free to help anyone?

                      edit:
                      ninjad by Hiredicespecter
                      set it in the phys material eh, ill give that a go thanks

                      Comment


                        #86
                        Originally posted by Hiredicespecter View Post
                        The 'air friction' your are looking for is called damping. It is NOT set in the script, it is set in the vehicles PhysicalMaterial and called AngularDamping (for turning) and linear damping (for movement).
                        I guess you have not assigned any to your vehicle. It needs to PhysMats btw. One when its driving and one when it's not driven. Have a look at the cicada content code.
                        Ah, thanks.

                        Comment


                          #87
                          @koningStoma: You're welcome.

                          @tegleg: In my last about 8 vids on youtube I calculate the counter force/torque to slowly stop rotation. ^^ The reason why I abandoned the physMat is that I aim for a somewhat hardcore simulation approach ;-) And I can use it later for stuff like auto pilot and AI. But in most cases the PhysMat will do a better job.

                          Comment


                            #88
                            While coding the plane for a buddy, I encountered the problem, GentlemanGraphics encountered (spinning, no response to input).

                            I forgot to added the lines

                            Code:
                            	DrivingPhysicalMaterial=PhysicalMaterial'VH_Cicada.materials.physmat_Cicada_driving'
                            	DefaultPhysicalMaterial=PhysicalMaterial'VH_Cicada.materials.physmat_Cicada'
                            to the default properties.

                            This is the same issue koningStoma, btw. It are always the small things bug you the most^^

                            Comment


                              #89
                              Today I fixed bug in the spaceship movement that has been bugging me for months.

                              When the ship is standing completely still in zero gravity (real GravityZ = 0, not -0.000001 or something) it would start to move downwards after some minutes. Downwards in the global sense.

                              The reason?

                              Code:
                              bFloatWhenDriven=true
                              in UTAirVehicle.

                              bFloatWhenDriven - If true, the vehicle will use a gravity Z-value of -0.1 to simulate floating. Useful for flying vehicles.
                              This makes sense for planes and helicopters, but not for spaceships. So add
                              Code:
                              bFloatWhenDriven=false
                              to the defaultproperties of your ship class you fix this issue.

                              More about the properties of the vehicle classes:
                              http://udn.epicgames.com/Three/Vehic...UDKVehicleBase

                              Comment


                                #90
                                so how do you get the mouse input in this?
                                PlayerController(Controller).PlayerInput.aMouseY always = 0
                                same with aStraffe and everything

                                single or multiplayer i dont mind

                                Comment

                                Working...
                                X