1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

karma ball movement

Discussion in 'Programming' started by zupafly, Nov 9, 2004.

  1. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    Hi,

    I created a karma ball which rolls down hills etc. Its spawned by using a pickup. So the player picks up the powerup, fires and then the ball spawns behind the player, I would want it to spawn with speed, meaning I want it to roll back once spawned with a certain speed. Anyone knows how ?

    I tried using KStartLinVel =-200,0,0 in my KarmaParams, but it only works well if my ball doesnt rotate and when bKAllowRotate=False its kinda ugly cause then the ball doesnt seem to roll but just move.
     
  2. ZarQa

    ZarQa Freelance coder

    Joined:
    Jul 11, 2003
    Messages:
    40
    Likes Received:
    0
    I'm not sure if this works, but you can give the object a velocity. You would do that like so:

    Code:
    local float Speed;
    local vector Direction;
    local KActor Ball;
    
    Ball = Spawn(class'yourpackage.yourball');
    //Speed and direction need to be changed to a value that fits your purpose.
    Ball.Velocity = Speed * Direction;
    
     
  3. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    thx for reply, I tried it before and didnt work either, I think problem is the rotating of the ball maybe I should set some karma physics different. I can make ball move perfectly using these command or with KStartLinVel stuff but then it moves instead of "roll" because I have to turn off bKAllowRotate to get it to work, else it doesnt really do much.

    Code:
    egin Object Class=KarmaParamsRBFull Name=KarmaParams0
             Kmass=3.5000000
             KStartEnabled=True
             bClientOnly=False
             bKAllowRotate=True
             KFriction=0.250000
             KRestitution=0.750000
             KImpactThreshold=1.000000
             KStartLinVel =-200,0,0
    
             KActorGravScale=1
             KLinearDamping=0
             KAngularDamping=0.000000
             bKDoubleTickRate=True
             KInertiaTensor(0)=0.100000
             Name="KarmaParams0"
         End Object
    
     
  4. porkmanii

    porkmanii New Member

    Joined:
    Sep 9, 2004
    Messages:
    129
    Likes Received:
    0
    Have you tried using KAddImpulse? I'm not exactly sure on how to use it, but U4eT's Industrial Anti-gravity Mover uses KAddImpulse to drag ragdolls around (by a specific bone)..
     
  5. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    no havent used it but I dont wanna "drag" my karma object, it needs to roll, moving it is no problem but moving it rolling is. I'll give it try though but it just needs to move for little time, maybe I better make it a projectile to "shoot" ball off.
     
  6. [SAS]Solid Snake

    [SAS]Solid Snake New Member

    Joined:
    Jun 7, 2002
    Messages:
    2,633
    Likes Received:
    0
    Use KApplyForces to adjust the Torque and Force. You'll have to learn how to calculate the Torque from a position force however.
     
  7. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    thx for reply, ball is moving nicely now. I still have a question though, I'm trying to make it spawn behind the player so I set x to -50 for the spawn, so normally if player is facing normal way it does spawn behind, but if player rotates or something it spawn like on his side or sometimes infront ? Any way I can see which direction player is facing ?
     
  8. porkmanii

    porkmanii New Member

    Joined:
    Sep 9, 2004
    Messages:
    129
    Likes Received:
    0
    The Pawn's Rotation would tell you what direction it is facing..
     
  9. [SAS]Solid Snake

    [SAS]Solid Snake New Member

    Joined:
    Jun 7, 2002
    Messages:
    2,633
    Likes Received:
    0
    Code:
    vector offset >> adjustment rotation
    
    For more info, look in ProjectileFire.uc
     
  10. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    I used this coding, the locationtarget is behind the location of the instigator. So if I put the rotation of the instigator like this the ball comes out the same rotation angle as the instigator is at that moment ?

    It seemed to be so ingame but dunno if it's right, it looks right ingame

    Code:
    RotatorTarget = Instigator.Rotation;
    Spawn(class'RcRacing.RcBal', Instigator,,LocationTarget,RotatorTarget);
    
     
  11. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    When the ball is spawned it rolls out right direction but when facing other direction it still rolls out in same direction. I know it has got to do with the direction in unreal. But how can I see which direction car is facing ? North South ?

    Code:
    event KApplyForce(out vector Force, out vector Torque)
    {
      Force=vect(0,-5,0);
      Torque=vect(0,-5,0);
    }
    I use this coding to spawn ball but it has to 5 if car is facing other direction but I dont know how to get car direction properly. Rotation has 3 variables if it is right thing to look at which one should be what value then to be in certain direction ?
     
  12. porkmanii

    porkmanii New Member

    Joined:
    Sep 9, 2004
    Messages:
    129
    Likes Received:
    0
    Read this.

    Rotators have 3 parts:
    - Pitch (think up/down... like nodding your head "yes")
    - Yaw (think left/right... like shaking your head "no")
    - Roll (tilt your head to one side, so you're still looking the same direction, but one ear is pointing up and the other down).


    Edit:
    You'll want to use all three, or at least the first two. i.e.:
    Code:
    event KApplyForce(out vector Force, out vector Torque)
    {
      Force = Vector(Rotation) * 5;
      Torque = Force;
    }
     
    Last edited: Feb 5, 2005
  13. zupafly

    zupafly New Member

    Joined:
    Aug 13, 2004
    Messages:
    147
    Likes Received:
    0
    thx for explaning works now :)
     

Share This Page