Announcement

Collapse
No announcement yet.

How does a projectile Spin?

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

    How does a projectile Spin?

    What projectile propertie makes it go forward? i made a new projectile but when i shoot it just kinda floats. i gave it gravity but then it just fell if you can tell me how to make it go forward i would be really greatfull.

    #2
    Speed is it's speed, if you want it to fall Phys_Falling go straight Phys_Projectile

    Comment


      #3
      I did make it a projectile physics but when i do that it just floats.

      Comment


        #4
        Did you set its velocity in PostBeginPlay?
        Code:
        simulated function PostBeginPlay()
        {
            Super.PostBeginPlay();
        
            if (Role == ROLE_Authority)
            {
                Velocity = Vector(Rotation) * Speed;
            }
        }

        Comment


          #5
          Basically, Velocity is the direction and speed vector for a projectile. Does your projectile have a speed and maxspeed entry in it's defaultproperties? It would help if you posted the code for your projectile and whatever spawns it.

          Comment


            #6
            Thanks it goes forward now i just need to add collision data. by the way do you know how to make a projectile spin in air? if its complex never mind but if its just some animation data looping id like to learn how.

            Code:
            class bricklauncherprojectiletwo extends projectile;
            
            #exec OBJ LOAD FILE=BrickLauncher.utx
            
            simulated function PostBeginPlay()
            {
                Super.PostBeginPlay();
            
                if (Role == ROLE_Authority)
                {
                    Velocity = Vector(Rotation) * Speed;
                }
            }
            
            defaultproperties
            {
               DrawScale3D=(X=1,Y=1,Z=1)
               Physics=PHYS_Projectile
               bFixedRotationDir=false
               DesiredRotation=(Pitch=12000,Yaw=5666,Roll=2334)
               DrawType=DT_StaticMesh
               StaticMesh=StaticMesh'BrickLauncher.Hammerprj'
               MaxSpeed=5750
               Speed=5750
               Damage=30
               LifeSpan=18

            Comment


              #7
              You could always put the number up on one of the rotator axis by so much every tick, though that would probably not be the most elegant way to do it...


              ex:
              Code:
              simulated function Tick (float DT)
              {
                  local rotaor rot;
              
                  if (Level.NetMode != NM_DedicatedServer)
                  {
                      rot = rotation;
                      rot.yaw += 5;
                      SetRotation(rot);
                  }
                  Super.Tick(DT);
              }

              Comment


                #8
                Where would i put that code I pasted it into the projectile class, but it doesen't recognize the rotaor would i put in the inventory class?

                Comment


                  #9
                  It should go in the projectile lcass, what element does it not recognize?

                  Comment


                    #10
                    the rotaor

                    Comment


                      #11
                      theres a spelling error in what i posted
                      local rotaor rot;

                      should be
                      local rotator rot;;

                      Comment


                        #12
                        If I'm not mistaken, this should make it spin in all three directions.

                        Code:
                        var bool bSpun;
                        var() rotator Spin;
                        
                        event KApplyForce (out vector Force, out vector Torque)
                        {
                            if(!bSpun)
                            {
                                Torque += Spin;
                                bSpun = true;
                            }
                        }
                        
                        defaultproperties
                        {
                            Spin=(Pitch=100,Roll=50,Yaw=20)
                        }
                        Mess with the Spin property to make it spin in different ways.

                        Comment


                          #13
                          k ill try your way i did the first way but i dont think my weapon ticks.

                          Edit////////////
                          Nope says = types are incompatible which is this line
                          Code:
                          if(!bSpun)
                                  {
                                  Torque += Spin;
                                  bSpun = true;
                                  }

                          Comment


                            #14
                            Ah, sorry. Torque is a vector, not a rotator. Here's a bit of code that I actually use (so I know it works):
                            Code:
                            simulated function KApplyForce(out vector Force, out vector Torque)
                            {
                                super.KApplyForce(Force, Torque);
                            
                                if(bDriving
                                && JumpDurationRemaining > 0.0)
                                {
                                    Force += (JumpForce >> Rotation);
                                    Torque += (JumpTorque >> Rotation);
                                }
                                else if(bDriving
                                && bDucking)
                                {
                                    // Rotating DuckForce according to Rotation causes
                                    // the vehicle to slide up slopes when ducking.
                                    // DuckForce needs to simply always be downwards.
                                    //Force += (DuckForce >> Rotation);
                                    Force += DuckForce;
                                    Torque += (DuckTorque >> Rotation);
                                }
                            }
                            This is basically a rewrite of the same bit in ONSHoverCraft, with an extra bell & whistle. JumpForce and JumpTorque are defaultproperties, the rest are class-level variables.

                            Comment


                              #15
                              KApply force might not work since a porjectile is a non-Karma physics actor, in that case just adjust the rotation variable (it's a rotator) of the projectile (rotation.yaw (or pitch, or roll whichever works)) += 5; )

                              Comment

                              Working...
                              X