Page 1 of 2 12 LastLast
Results 1 to 40 of 47
  1. #1
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default Help With A research project using UDK(FOR PSYCHOLOGY)

    Hello , let me introduce myself. My name is Andres Sepulveda, i'm a Psychologist from Chile,and beacuause a like game development i worked on it for a time on my own projects,using other frameworks and engines.
    Ok the actual situation is that coleague of mine ask me help for a research in my field. The research consist in measuring the deviation and collision that a driver could have when he is writing a message(twitter by example) while driving a car, through a straight lane. When this happen, must write the crash time and position on a file so then we can make a graph with the information gathered, and compare it for each test subject.
    So i offer myself for this research experiment, and i was just reading about UDK development for experimenting the tool, and ia decided to use this engine for developing the game for this research. So this is what i have done this far. the level design



    i have created a kismet secuence for getting the player inside the car at the start


    and i created a script that register the position, X Y Z for the player, and show it on screen for debugging purposes.the position is recorded every second


    But now, i have almost a week trying to get the next part of the experiment:detect when the car hit one of the walls on the side and save this information to a file, (time and position when it occurs)
    i have tried kismet and script but i cant get that UDK detect the collision ,i have tried using hit wall, touch events and nothing changes. So i decided ask for help to the experts...and here i am. rocking like a hurricane haha.


    Thank you very much. if the research gets published i will post it . and sorry if my english it's no so good.

  2. #2
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Try a bump event? Post your relevant code as well in case there is a simple error that you're missing

  3. #3
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    im sorry , how can i use bump event to display on screen the position that you bumped, and log it to a file?

  4. #4
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Quote Originally Posted by DonFrag View Post
    ...i have tried kismet and script but i cant get that UDK detect the collision ,i have tried using hit wall, touch events and nothing changes.
    I was just answering this part of the equation

    As for displaying the position on the screen - you could display it like a HUD - create a new playercontroller class and put a new DrawHUD() fn in it. You can use setPos() and DrawText() (in Canvas) to draw text to the screen.

    No idea how to write it to a file... but what you could do if you're really desperate is to create an array in one of your classes (maybe the same playercontroller class above) and keep adding items to it when you hit something - like the time, location, speed, etc.

    When the game exits or you press a certain key you could dump that array to the log and then manually cut and paste it. It's not elegant but it would work.

  5. #5
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Location
    Prayols, France
    Posts
    162

    Default

    If you read the postion of the car every second, you can know how far from the center of the road it is ^^.
    You don't need a collision for your purpse, just a little " if (myCar_Y >= myRoadWidth/2 || myCar_Y <= -myRoadWidth/2) { // Do what you want}; " in your car position function. This is working only if your road still straight, of course .

  6. #6
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    this is my start point(referenced inside udk as default mode)
    Code:
    class BaseGame extends FrameworkGame;
    
    defaultproperties
    {
        PlayerControllerClass =class 'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type
        DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type
        HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type
        bDelayedStart = false //If TRUE, the game will not immediately begin when the player joins.
    }
    MyHud
    Code:
    lass MyHud extends MobileHUD;
    
    var CanvasIcon clockIcon;
    var int clock; 
    var config vector PlayerLocation;
    
    
    
    function DrawHUD()
    {
      Canvas.SetPos(Canvas.ClipX/2,Canvas.ClipY/2);
    
    Canvas.SetDrawColor(255,255,255,255);
    
    Canvas.Font = class'Engine'.static.GetMediumFont();
    PlayerLocation=GetALocalPlayerController().Pawn.Location;
    
    
    Canvas.DrawText(playerLocation);    
    
    }
    defaultproperties
    {
     clockIcon=(Texture=Texture2D'UDKHUD.Time')  
    }
    my pawn
    Code:
    class MyPawn extends Pawn;
    
    var DynamicLightEnvironmentComponent LightEnvironment;
    
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(self,"Bumped");
    }
    
    defaultproperties
    {
       
    }
    my car
    Code:
    class CarPLayer extends UTVehicle_Scorpion;
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(self,"Car Bumps!");
    }
    
    
    
    defaultproperties
    {
        
    }
    so i what i have got so far is this:
    1-when the game starts, i put the player inside of the scorpion using Kismet.
    2-If the car hit a wall, nothing happens.
    3if the player get down of the car, and touch a wall, the server sends a message ('bumped')

    so my option now are make that the vechicle bump and message or convert the pawn into a scorpion car

  7. #7
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    I was going to suggest that you override the bump function of the vehicle class, but I can see that you have already done that. I'd try putting the bump function in your playerController class, rather than the pawn to see if that works.

  8. #8
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Quote Originally Posted by DonFrag View Post
    ...
    2-If the car hit a wall, nothing happens.
    Bump and HiWall:
    Bump is called on Actor which was hit by Other actor
    HitWall vice versa - Other will receive an even.

    HitWall by default is disabled in Pawn, but you can enable it by adding bDirectHitWall=True to default properties of your vehicle. Now you can use HitWall...

    Quote Originally Posted by paco View Post
    I'd try putting the bump function in your playerController class, rather than the pawn to see if that works.
    Controllers doesn't collide - imagine them as a kind of ghosts...
    Last edited by VendorX; 05-03-2012 at 01:02 PM.

  9. #9
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Quote Originally Posted by VendorX View Post
    Controllers doesn't collide - imagine them as a kind of ghosts...
    True. I was thinking of NotifyBump() - they don't collide but they do receive collision notifications and I was wondering if the controller choosed not to pass on bump events when it was controlling a vehicle.

  10. #10
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    ok i tried this
    Code:
    class CarPLayer extends UTVehicle_Scorpion;
    
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car Bumps!");
    }
    
    event HitWall(Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car hitwall!");
    }
    
    event RanInto (Actor Other)
    {
         WorldInfo.Game.Broadcast(GetALocalPlayerController(),Other);
    }
     
     simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
     {
           WorldInfo.Game.Broadcast(GetALocalPlayerController(),HitComponent);
            WorldInfo.Game.Broadcast(GetALocalPlayerController(),OtherComponent);
          
           
     }
    defaultproperties
    {
        bDirectHitWall=True;
        
    }
    Code:
    class MyPawn extends Pawn;
    
    var DynamicLightEnvironmentComponent LightEnvironment;
    
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(self,"Driver Bumped");
         WorldInfo.Game.Broadcast(self,Other);
    }
    
    event HitWall(Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Get driver hitwall!");
    }
    
    defaultproperties
    {
         bDirectHitWall=True;
       
    }
    and still not working, just shows the messages from the driver when he is outside the car.(when he touch a wall or the car). when the car touch the wall nothing happens.

    my guess are:
    1-it doesnt work beacause the scorpion is not the pawn, it has a pawndriver inside, son when ir crashes, the driver inside doesn't
    2- the scorpion created inside the game doesnt get que script that i made

  11. #11
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Well each of the actors has a PostBeginPlay() method - you can print a log message there to see if your class is being used ( I tend to prefer using `log() rather than Broadcast but i'm not sure why!)

  12. #12
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    Code:
    class CarPLayer extends UTVehicle_Scorpion;
    
    simulated event PostBeginPlay(){
            super.PostBeginPlay();
       
        
            WorldInfo.Game.Broadcast(self,"Car Initialized!!");
        
    }
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car Bumps!");
    }
    
    event HitWall(Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car hitwall!");
    }
    event bool DriverLeave (bool bForceLeave)
    {
            WorldInfo.Game.Broadcast(GetALocalPlayerController(),"ADIOS");
            return true;
     
    }
    event RanInto (Actor Other)
    {
         WorldInfo.Game.Broadcast(GetALocalPlayerController(),Other);
    }
     
     simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
     {
           WorldInfo.Game.Broadcast(GetALocalPlayerController(),"oli");
            WorldInfo.Game.Broadcast(GetALocalPlayerController(),"OLI2");
          
           
     }
    defaultproperties
    {
         bDirectHitWall=True;
        
    }
    the script is not loaded because no message is shown mmm

  13. #13
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Looking at the kismet you are using to spawn the vehicle it looks like you are spawning a UTVehicle, rather than your own class

  14. #14
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Is not loaded, because you using UTVehicleFactory_Scorpion...

    CarPLayer:
    Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    
    simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
    {
           Super.RigidBodyCollision(HitComponent, OtherComponent, Collision, ContactIndex);
           ClientMessage("RigidBodyCollision.OtherComponent:"@OtherComponent);       
    }
    
    defaultproperties
    {
    }
    You can spawn CarPLayer by ActorFactory -> UTActorFactoryVehicle -> CarPLayer and use Possess Pawn...

    ...or write custom vehicle factory...

    VehicleFactory:
    Code:
    class UTVehicleFactory_CarPLayer extends UTVehicleFactory_Scorpion;
    
    defaultproperties
    {
    	VehicleClassPath="CarPLayer"
    }
    ...and use Enter Vehicle.

  15. #15
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    I finally got it, following the help above, plus some changes i had to do for get this working

    Code:
    class MyVechicleFactory extends UTVehicleFactory_Scorpion;
    
    defaultproperties
    {
        VehicleClass=class'CarPLayer'
        
    }
    Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    var config vector PlayerLocation;
    
    
    simulated event PostBeginPlay(){
           
        WorldInfo.Game.Broadcast(self,"Car Initialized!!");
        
    }
    event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car Bumps!");
    }
    
    event HitWall(Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
    {
        WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Car hitwall!");
    }
    event bool DriverLeave (bool bForceLeave)
    {
            WorldInfo.Game.Broadcast(GetALocalPlayerController(),"ADIOS");
            return true;
     
    }
    event RanInto (Actor Other)
    {
         WorldInfo.Game.Broadcast(GetALocalPlayerController(),Other);
    }
     
     simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
     {
         
         PlayerLocation=GetALocalPlayerController().Pawn.Location;
    
           WorldInfo.Game.Broadcast(GetALocalPlayerController(),PlayerLocation);
           
           
     }
    defaultproperties
    {
         bDirectHitWall=True;
        
    }
    the event simulated event RigidBodyCollision was fired when i hit a wall.
    besides i had to delete the scorpion that was in the game and i replaced with Mycar who appeared in the actor class tree, under utvehicle_scorpion.
    now im going to findout how to write de info in a file.

  16. #16
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Quote Originally Posted by DonFrag View Post
    ...
    now im going to findout how to write de info in a file.
    What do you need..?

  17. #17
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    besides of the position, i have to capture the time when the hit occurs, and then write that data into a file.
    so then i can use them for a graphic of time vs position (for studies purposes)
    Last edited by DonFrag; 05-05-2012 at 03:07 AM.

  18. #18
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    You can make a struct...
    Code:
    struct SCollisionsList
    {
    	var vector HitLocation;
    	var int HitDamage;
    	var float HitTime;
    };
    var array< SCollisionsList> CollisionsList;
    ...and collect data when collision occur...
    Code:
    local SCollisionsList LastCollision;
    
    LastCollision.HitLocation  =  Collision.ContactInfos[0].ContactPosition;
    LastCollision.HitDamage = int(VSizeSq(Mesh.GetRootBodyInstance().PreviousVelocity) * GetCollisionDamageModifier(Collision.ContactInfos));
    LastCollision.HitTime = WorldInfo.TimeSeconds;
    
    CollisionsList.AddItem(LastCollision);
    Now you need some SaveSystem and at the end of test save all data to the file.
    Last edited by VendorX; 05-05-2012 at 03:21 AM.

  19. #19
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    now it works
    i added a Triiger in the end with the tag 'MetaFinal'
    Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    var config vector PlayerLocation;
    var int CurTime;
    struct SCollisionsList
    {
        var vector HitLocation;
        var float HitTime;
    };
    var array< SCollisionsList> CollisionsList;
    var string html;
    event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
    {
            local FileWriter FW;
            local string sTag;
            local string FinishTag;
            local int index;
            FinishTag="MetaFinal";
            sTag=string(other.Tag);
            html="";
            
              if(sTag==FinishTag)
              {
                          for (index = 0; index < CollisionsList.Length; ++index) {
                              html=html$"<tr><td>"$CollisionsList[index].HitLocation$"</td><td>"$CollisionsList[index].HitTime$"</tr>";
                  }
                   FW =  spawn(class'FileWriter');
            FW.OpenFile("results",FWFT_HTML );
            html="<html><body><table width='200' border='1'>"$html$"</table></body></html>";
            
            fw.Logf(html);
            FW.CloseFile();
         }
            
    
       
    }
    
     simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
     {
            local SCollisionsList LastCollision;
          
          PlayerLocation=GetALocalPlayerController().Pawn.Location;
          WorldInfo.Game.Broadcast(GetALocalPlayerController(),PlayerLocation);
          WorldInfo.Game.Broadcast(GetALocalPlayerController(),WorldInfo.TimeSeconds );
       
          
    LastCollision.HitLocation  =  Collision.ContactInfos[0].ContactPosition;
    LastCollision.HitTime = WorldInfo.TimeSeconds;
    
    CollisionsList.AddItem(LastCollision);
    
    
    
           
           
           
     }
    defaultproperties
    {
         bDirectHitWall=True;
        
    }
    the output is this
    HTML Code:
    <html><body><table width='200' border='1'><tr><td>3604.73,2457.14,41.75</td><td>4.7326</tr><tr><td>3609.22,3902.53,44.13</td><td>6.4843</tr><tr><td>3608.68,5965.42,40.13</td><td>8.6100</tr><tr><td>3608.28,8336.55,100.33</td><td>10.9884</tr></table></body></html>
    nice ah?
    now im going to refine the code and level design

  20. #20
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    now im waiting for the proffesor's aproval so i can move on.
    thank you all by the way,soon i'll comment further advances

  21. #21
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    now i have a new question.
    i was ask to make a circuit for the player. a oval shape . but i was asked to two things
    1-a start timer (3 2 1 go!) and then the car start to moe forward automatically .so the driver has to move to left or the right only. I made the countdown like this:
    Code:
    class BaseGame extends UDKGame;
    var SoundCue beep;
    var int CurTime;
    var bool bPlayed;
    var int LastTime;
    event PostLogin( PlayerController NewPlayer )
    {
        super.PostLogin(NewPlayer);
        // NewPlayer.ClientMessage("Welcome to the grid "$NewPlayer.PlayerReplicationInfo.PlayerName);
        NewPlayer.ClientMessage("Point at an object and press the left mouds button to retrieve the target's information");
        
    }
    
    event Tick(float DeltaTime)
    {  
      // WorldInfo.Game.Broadcast(GetALocalPlayerController(),Abs(WorldInfo.TimeSeconds));
       // homing_beacon_Cue
       CurTime=WorldInfo.TimeSeconds;
       if(CurTime==1)
         LastTime=1;
        
       if(CurTime==3)
       {
           if( LastTime==1)
           {
           WorldInfo.Game.Broadcast(GetALocalPlayerController(),"3");
          PlaySound(beep);
          LastTime=3;
            }
       }
        
        if(CurTime==4)
            {
                if( LastTime==3)
           {
               WorldInfo.Game.Broadcast(GetALocalPlayerController(),"2");
          PlaySound(beep);
          LastTime=4;
            }
           }
       
          if(CurTime==5)
           {
              if( LastTime==4)
           {
               WorldInfo.Game.Broadcast(GetALocalPlayerController(),"1");
          PlaySound(beep);
          LastTime=5;
            }
           } 
       
           if(CurTime==6)
           {
               if( LastTime==5)
           {
               WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Comienzo!!");
          PlaySound(beep);
          LastTime=6;
            }
            }
       
           
    }
    defaultproperties
    {
       
        PlayerControllerClass =class 'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type
        DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type
        HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type
        bDelayedStart = false //If TRUE, the game will not immediately begin when the player joins.
         beep=SoundCue'KismetExamples.homing_beacon_Cue'    
         
     
    }
    but i can't find the way so the car starts to moe forward by itself.
    2-following the same, when the circuit its over the car must stop

    i tried watching the default properties of the scorpion vehicle, but it looks like you can control the max speed, but you can't set a base speed.

  22. #22
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    i found a function MoveTo() but i can't get it work

  23. #23
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    What you could do is over-ride the playermove function that handles input - you should be able to set a forward velocity there. I think it's in the controller.

  24. #24
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    ok i did it!
    this is my new code

    PHP Code:
    class MyGamePlayerController extends GamePlayerController ;
    var 
    BaseGame cBaseGame;
        
    state PlayerDriving
    {
      
        function 
    PlayerMovefloat DeltaTime )
        {
            
    local float ForwardStrafe;
            
    local bool bState;
           
            
            
    cBaseGame=spawn(class'BaseGame');
        
    UpdateRotation(DeltaTime);

        
    // Get the forward input information
        
    Forward PlayerInput.aForward;
        
    // Get the strafe input information
        
    Strafe PlayerInput.aStrafe;

        if (
    PlayerInput != None)
        {
          
    Forward = (((PlayerInput.aTilt.UnrRotToDeg) - 30.f) / 50.f) * -1.f;
        }

        
    // Clamp the forward to within -1.f and 1.f
        
    Forward FClamp(Forward, -1.f1.f);
       
        
    ProcessDrive(ForwardStrafePlayerInput.aUpbPressedJump);

        if (
    Role ROLE_Authority)
        {
          
    ServerDrive(PlayerInput.aForwardPlayerInput.aStrafePlayerInput.aUpbPressedJump, ((Rotation.Yaw 65535) << 16) + (Rotation.Pitch 65535));
        }

        
    bPressedJump false;
        
    //if the counter gets to start! in BaseGame.uc send a message for debugging purposses
        //this is not working. its not capturing the BaseGame.Move variable value
        
    bState=cBaseGame.Move;
        if(
    bState==true)
        
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),bState);
        
      }
    }

    defaultproperties{
        
    bFreeLook false// to disable free look with mouse
    bMousing false// to disable mousing


    now im trying the next thing. when in basegame script the countDown gets to 0 , we set a ar flag t true, and the game start but if i read the var Move in the BaseGame Class, it doesn't get the value;
    On the posted script, from the line that starts from
    bPressedJump = false;
    manage that

    this is the base game class the line that start with
    if(CurTime==6)

    manage the code to set the Move Flag


    PHP Code:
    class BaseGame extends UDKGame;
    var 
    SoundCue beep;
    var 
    int CurTime;
    var 
    bool bPlayed;
    var 
    int LastTime;
    var 
    bool Move;

    event PostLoginPlayerController NewPlayer )
    {
        
    super.PostLogin(NewPlayer);
        
    // NewPlayer.ClientMessage("Welcome to the grid "$NewPlayer.PlayerReplicationInfo.PlayerName);
        
    NewPlayer.ClientMessage("Point at an object and press the left mouds button to retrieve the target's information");
        
    Move=false;
        
    }

    event Tick(float DeltaTime)
    {  
      
    // WorldInfo.Game.Broadcast(GetALocalPlayerController(),Abs(WorldInfo.TimeSeconds));
       // homing_beacon_Cue
       
    CurTime=WorldInfo.TimeSeconds;
       if(
    CurTime==1)
         
    LastTime=1;
        
       if(
    CurTime==3)
       {
           if( 
    LastTime==1)
           {
           
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"3");
          
    PlaySound(beep);
          
    LastTime=3;
            }
       }
        
        if(
    CurTime==4)
            {
                if( 
    LastTime==3)
           {
               
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"2");
          
    PlaySound(beep);
          
    LastTime=4;
            }
           }
       
          if(
    CurTime==5)
           {
              if( 
    LastTime==4)
           {
               
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"1");
          
    PlaySound(beep);
          
    LastTime=5;
            }
           } 
       
           if(
    CurTime==6)
           {
               if( 
    LastTime==5)
           {
               
    //here the game start!
               
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Comienzo!!");
          
    PlaySound(beep);
          
    //set the car to be able to move 
          
    Move=true;
            }
             
            }
       
           
    }
    defaultproperties
    {
       
        
    PlayerControllerClass=class'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type
        
    DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type
        
    HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type
        
    bDelayedStart false //If TRUE, the game will not immediately begin when the player joins.
         
    beep=SoundCue'KismetExamples.homing_beacon_Cue'    
         
     

    as a programmer i think that im instancing in MyGamePLayer... from the class BaseGame definition, so een if it get the var Move Changed, on the MygamePLayer class, it neve get the new value because it is created from the definition and not from new state of the class.

    there is another way to access to the var Move?
    Last edited by DonFrag; 05-29-2012 at 12:01 AM.

  25. #25
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    Every time you create a new version of your BaseGame class it gets the default values. Try creating a single version of your class in the PostBeginPlay function of your controller - ie, move the line "cBaseGame=spawn(class'BaseGame');" to there rather than in the PlayerMove function.

  26. #26
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    ok i did it and now it works. btw im posting all the scripts because i think that this could help other, sorry for the flooding.
    when the timer goes to 0 the car start to move and you cand drive it
    when the time goes up (in this example, when the time is over 12 seconds) the car is forced to stop.
    the timer variables control are in the basegame class, and the moving and stopping code are on playercontroll class.

    tomorrow i have a metting with the proffesor to see how is the project going.

    PHP Code:
    class MyGamePlayerController extends GamePlayerController ;
    var 
    BaseGame cBaseGame;
        
    simulated event PostBeginPlay(){
            
    super.PostBeginPlay();
            
    cBaseGame=spawn(class'BaseGame');
      
        
    }

    state PlayerDriving
    {
      
        function 
    PlayerMovefloat DeltaTime )
        {
            
    local float ForwardStrafe;
            
    local bool bState;
            
            
    bState=cBaseGame.Move;
            
                   
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),bState);
           
                   
         
    //if the counter gets to start! in BaseGame.uc send a message for debugging purposses
        //this is not working. its not capturing the BaseGame.Move variable value  
            
    if(bState==true)
            {
             
            
    UpdateRotation(DeltaTime);

            
    // Get the forward input information
            
    Forward PlayerInput.aForward;
            
    // Get the strafe input information
            
    Strafe PlayerInput.aStrafe;

                        if (
    PlayerInput != None)
                        {
                          
    Forward = (((PlayerInput.aTilt.UnrRotToDeg) - 30.f) / 50.f) * -1.f;
                        }

                    
    // Clamp the forward to within -1.f and 1.f
                    
    Forward FClamp(Forward, -1.f1.f);
                   
                    
    ProcessDrive(ForwardStrafePlayerInput.aUpbPressedJump);

                      

                    
    bPressedJump false;
                 
              }
                else
                {
                        
    ProcessDrive(00PlayerInput.aUpbPressedJump);

                }
              
            }
            
    }

    defaultproperties{
        
    bFreeLook false// to disable free look with mouse
    bMousing false// to disable mousing

    PHP Code:
    class BaseGame extends UDKGame;
    var 
    SoundCue beep;
    var 
    int CurTime;
    var 
    bool bPlayed;
    var 
    int LastTime;
    var 
    bool Move;

    event PostLoginPlayerController NewPlayer )
    {
        
    super.PostLogin(NewPlayer);
        
    // NewPlayer.ClientMessage("Welcome to the grid "$NewPlayer.PlayerReplicationInfo.PlayerName);
        
    NewPlayer.ClientMessage("Point at an object and press the left mouds button to retrieve the target's information");
        
    Move=false;
        
    }

    event Tick(float DeltaTime)
    {  
      
    // WorldInfo.Game.Broadcast(GetALocalPlayerController(),Abs(WorldInfo.TimeSeconds));
       // homing_beacon_Cue
       
    CurTime=WorldInfo.TimeSeconds;
       if(
    CurTime==1)
         
    LastTime=1;
        
       if(
    CurTime==3)
       {
           if( 
    LastTime==1)
           {
           
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"3");
          
    PlaySound(beep);
          
    LastTime=3;
            }
       }
        
        if(
    CurTime==4)
            {
                if( 
    LastTime==3)
           {
               
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"2");
          
    PlaySound(beep);
          
    LastTime=4;
            }
           }
       
          if(
    CurTime==5)
           {
              if( 
    LastTime==4)
           {
               
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"1");
          
    PlaySound(beep);
          
    LastTime=5;
            }
           } 
       
           if(
    CurTime==6)
           {
               if( 
    LastTime==5)
                   {
                       
    //here the game start!
                       
    WorldInfo.Game.Broadcast(GetALocalPlayerController(),"Comienzo!!");
                  
    PlaySound(beep);
                  
    //set the car to be able to move 
                  
    Move=true;
                    }
            }
       
            
    //set the end of the game
              
    if(CurTime>12)
              {
                  
                  
    Move=false;
              
              }
                  
           
    }
    defaultproperties
    {
       
        
    PlayerControllerClass=class'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type
        
    DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type
        
    HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type
        
    bDelayedStart false //If TRUE, the game will not immediately begin when the player joins.
         
    beep=SoundCue'KismetExamples.homing_beacon_Cue'    
         
     


  27. #27
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    Hello now i have this problem.
    when the car touch a trigger placed on the field, "MessageHud" takes the value of the random number generated, and it works, when i show it with the console GetALocalPlayerController().ClientMessage(MessageH ud);
    PHP Code:
    class BaseGame extends UDKGame;
    var 
    SoundCue beep;
    var 
    int CurTime;
    var 
    bool bPlayed;
    var 
    int LastTime;
    var 
    bool Move;
    var 
    string sMessage;


    event PostLoginPlayerController NewPlayer )
    {
        
    super.PostLogin(NewPlayer);
         
    }

    event Tick(float DeltaTime)
    {  
         
    local MyHud bHud;
            
    bHud=spawn(class'MyHud');
         
        
    CurTime=WorldInfo.TimeSeconds;
       if(
    CurTime==1)
        
    LastTime=1;
       
        
       if(
    CurTime==2)
       {
           
    bHud.DrawHudText("3");
        
           if( 
    LastTime==1)
           {
              
               
    PlaySound(beep);
               
    LastTime=2;
               
            }
       }
      
       if(
    CurTime==3)
       {
           
    bHud.DrawHudText("2");
          if( 
    LastTime==2)
           {
               
               
    PlaySound(beep);
               
    LastTime=3;
               
            }
       }
        
      if(
    CurTime==4)
       {
             
    bHud.DrawHudText("1");    
             
           if( 
    LastTime==3)
           {
               
    PlaySound(beep);
               
    LastTime=4;
               
            }
       }
       
      if(
    CurTime==5)
       {  
           
    bHud.DrawHudText("Comienzo!!");    
          if( 
    LastTime==4)
           {
               
    Move=true;
               
    PlaySound(beep);
               
    PlaySound(beep);
               
    PlaySound(beep);
              
               
            }
       }
      
       
       
    }
    defaultproperties
    {
       
        
    PlayerControllerClass=class'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type
        
    DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type
        
    HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type
        
    bDelayedStart false //If TRUE, the game will not immediately begin when the player joins.
         
    beep=SoundCue'KismetExamples.homing_beacon_Cue'    
         
         
     

    PHP Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    var 
    config vector PlayerLocation;
    var 
    int CurTime;
    struct SCollisionsList
    {
        var 
    vector HitLocation;
        var 
    float HitTime;
    };
    var 
    int lap;
    var array< 
    SCollisionsListCollisionsList;
    var 
    string html;
    var() 
    string MessageHud;
    var 
    bool ShowMessageHud;
    var 
    string nRand;

    simulated event PostBeginPlay(){
            
    super.PostBeginPlay();
           
        
    }
    simulated function bool CalcCamerafloat fDeltaTimeout vector out_CamLocout rotator out_CamRotout float out_FOV )
    {
         
    local vector XYZ;
        
    //this makes the camera stay with the vehicle
        
    GetActorEyesViewPointout_CamLocout_CamRot );

            
    GetAxes(Rotation,X,Y,Z);

            
    // a bit behind
            
    out_CamLoc Location 40 X;
            
    //up a bit
            
    out_CamLoc.Location.25;

        
    //camera rotation yaw = vehicle rotation yaw
        
    out_CamRot.Yaw Rotation.Yaw;
        
    //  look down a bit
        
    out_CamRot.Pitch = (-0.0f     *DegToRad) * RadToUnrRot;
        
    //delete this line if you want the cam to roll with the vehicle
        
    out_CamRot.Roll 0;

        return 
    true;
    }

    event Touch(Actor OtherPrimitiveComponent OtherCompvector HitLocationvector HitNormal)
    {
            
    local string MetaName;
            
    local MyHud bHud;
            
    bHud=spawn(class'MyHud');
            
            
            if(
    lap==0)lap=1;
           
            
    MetaName=string(Other);
            
            
            
         switch(
    MetaName)
         {
             case (
    "TriggerVolume_0"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
            break;
             
             case (
    "TriggerVolume_1"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_2"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_3"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_4"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_5"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_6"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_7"):
             
    ShowMessageHud=false;
             break;
             
             case (
    "TriggerVolume_8"):
             
    lap++;
             
    ShowMessageHud=true;
             
    MessageHud="Vuelta Numero "$lap;
             break;
             
             case (
    "TriggerVolume_9"):
             
    ShowMessageHud=false;
             break;
             
             
         }
          
    bHud.DrawHudText(MessageHud);
           
           
       
       
    }
    //this function generates a random number. eery lap the game increase the number lenght by one
    simulated function int  GenerateRandomNumber(int nLap)
    {
        
    local int sRandomNumber;
        
    local int nBase;
        
    local int Range1;
        
    local int Range2;
        
        
        
    nBase=3;
        
    Range1=10**(nLap+nBase-1);
        
    Range2=(10**(nLap+nBase))-1;
        
    sRandomNumber=intRandRange(Range1,Range2)); 
             
           return 
    sRandomNumber;
        
              
    }
     
    simulated event RigidBodyCollision (PrimitiveComponent HitComponentPrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collisionint ContactIndex)
     {
            
    local SCollisionsList LastCollision;
          
          
    PlayerLocation=GetALocalPlayerController().Pawn.Location;
             
    LastCollision.HitLocation  =  Collision.ContactInfos[0].ContactPosition;
    LastCollision.HitTime WorldInfo.TimeSeconds;

    CollisionsList.AddItem(LastCollision);
       
     }

    defaultproperties
    {
         
    bDirectHitWall=True;
        

    PHP Code:
    class MyHud extends MobileHUD;

    var 
    CanvasIcon clockIcon;
    var 
    int clock
    var 
    config vector PlayerLocation;
    var 
    int CurTime;
    var 
    int LastTime;
    var 
    SoundCue beep;
    var 
    bool Move;
    var 
    bool ShowHud;
    var 
    string SMessageHud;

       

    event PostRender()
    {
        
          
    Move=false;
      
    DisplayConsoleMessages();
     
    }


    function 
    DrawHudText(string sText)
    {
        
        
    SMessageHud=sText;
      
    DrawHUD();
        
    }

    function 
    DrawHUD()
    {
         
    Canvas.SetPos(Canvas.ClipX/2,Canvas.ClipY/2-200);
        
    Canvas.SetDrawColor(255255255);
    Canvas.Font = class'Engine'.static.GetLargeFont();
       
    GetALocalPlayerController().ClientMessage(SMessageHud);//this works
      
    Canvas.DrawText("mensaje");//this doesn't works

       

    }
    defaultproperties
    {
         

    Last edited by DonFrag; 06-10-2012 at 04:14 AM.

  28. #28
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    in the BaseGame i have a counter and try to call a instance of the MyHud class.
    inside of MyHud theres a custom functionwhere i pass the message that i want

    GetALocalPlayerController().ClientMessage(SMessage Hud);//this works
    Canvas.DrawText("mensaje");//this doesn't works

    i don't know why it doesn't show anything on the hud but it does on the console, so i can see that the value is being passed

  29. #29
    Palace Guard
    Join Date
    Feb 2010
    Location
    Tegleg Records
    Posts
    3,612
    Gamer IDs

    Gamertag: tegleg digital

    Default

    have you tried SetPos() before the drawtext, possibly its being drawn off the screen.

    Canvas.SetPos(100,100); //or wherever you want
    Canvas.DrawText("mensaje");
    Code:
    We.spazmodicaly.simulate.new.sound.with.technical.equipment.that.is.specificaly.manufactured.for.humans.to.communicate.in.outer.space.Tegleg.manipulates.time.and.space.to.create.new.experiences.to.generate.a.hardcore.database.generation.
    Please ask questions in the forum, NOT a private message
    tegleg.co.uk
    My Tutorials n Stuff
    Games: Tegs Playground - Unwheel2 - VCTF Game - Sponic Mesh 3D - Shh.. dont tell anyone about my android apps.
    will code for money

  30. #30
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    well....the code have a setPos line,
    anyway i changed it to 100,100 and i have the same problem
    Last edited by DonFrag; 06-10-2012 at 02:21 PM.

  31. #31
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    I'm not sure why it's not drawing for you - from what you say it seems that your DrawHUD() function is getting called, but DrawText() isn't working?

    It might be something to do with extending from MobileHud.... there are a few flags in that class like bShowGameHud you could try setting to true in the default properties?

    Also you could try adding a super.PostRender() in your PostRender function.

  32. #32
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    i changed to this
    PHP Code:
    class MyHud extends MobileHUD

    var 
    CanvasIcon clockIcon
    var 
    int clock;  
    var 
    config vector PlayerLocation
    var 
    int CurTime
    var 
    int LastTime
    var 
    SoundCue beep
    var 
    bool Move
    var 
    bool ShowHud
    var 
    string SMessageHud

        

    event PostRender() 

        
    super.PostRender() ;
      
    DisplayConsoleMessages(); 
      



    function 
    DrawHudText(string sText

       
        
    SMessageHud=sText
      
    DrawHUD() ;  
    }
      

    function 
    DrawHUD() 

         
    Canvas.SetPos(Canvas.ClipX/2,Canvas.ClipY/2-200); 
        
    Canvas.SetDrawColor(255255255); 
    Canvas.Font = class'Engine'.static.GetLargeFont(); 
      
    Canvas.DrawText("Test");//this works 
     
    GetALocalPlayerController().ClientMessage(SMessageHud);//this works 
      
    Canvas.DrawText(SMessageHud);//this doesn't works 

        


    defaultproperties 

      
          

    and i got this


    and it doesnt change all,
    the strange thing is :it shows the constant "test"
    it shows and display the var SMessageHud in the ClienMessage
    show nothing on Canvas.Draw Text.
    Last edited by DonFrag; 06-10-2012 at 10:49 PM.

  33. #33
    MSgt. Shooter Person
    Join Date
    Jun 2011
    Posts
    133

    Default

    Draw HUD will refresh every frame. Please check if SMessageHUD is not none every frame. In fact I don't think it's a good idea to display what boardcasted into HUD. It's strange. I suggest you to store the string you want to display directly into a variable.
    Your research is interesting. If you are in China, I can help handle all your features in two hours, for free... But however there is a two letters' distance(Chile ). Let's talk it on.

  34. #34
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    well i braodcast to check if the var SMessageHUD is being passed correctly.
    the Myhud class has var string SMessageHud; who stores the the value passed on the call of

    function DrawHudText(string sText)
    {

    SMessageHud=sText;
    DrawHUD() ;
    }

    so in the baseGame class its called this way

    event Tick(float DeltaTime)
    {
    local MyHud bHud;
    bHud=spawn(class'MyHud');

    CurTime=WorldInfo.TimeSeconds;

    if(CurTime==1)
    LastTime=1;


    if(CurTime==2)
    {
    bHud.DrawHudText("3");

    etc etc etc


    its that what you mean?


    im new on this. i hae programmed on other oo languages but this engine its kind of confusing to me i don't know why, so any help is welcome
    thank you a lot dprat for your help

  35. #35
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    i added this code
    PHP Code:
    function DrawHUD() 

        if( 
    SMessageHud==none)
        {
                
    Canvas.SetPos(Canvas.ClipX/2,Canvas.ClipY/2-200); 
            
    Canvas.SetDrawColor(255255255); 
        
    Canvas.Font = class'Engine'.static.GetLargeFont(); 
        
    //  Canvas.DrawText("Test");//this works 
        
    `Log("This is a call to ClientMessage:"$SMessageHud);
         GetALocalPlayerController().ClientMessage(SMessageHud );//this works 
         
    `Log("This is a call to Canvas:"$SMessageHud);
        
    Canvas.DrawText(SMessageHud );//this doesn't works 

        
    }


    got this log
    Code:
    0025.18] ScriptLog: This is a call to ClientMessage:3
    [0025.18] ScriptLog: This is a call to Canvas:3
    [0025.18] ScriptWarning: Accessed None 'Canvas'
    	myHUD UEDPIETest.TheWorld:PersistentLevel.myHUD_95
    	Function MyGame.myHUD:DrawHUD:0160
    [0025.18] ScriptWarning: Accessed None 'Canvas'
    	myHUD UEDPIETest.TheWorld:PersistentLevel.myHUD_96
    	Function MyGame.myHUD:DrawHUD:000A
    [0025.18] ScriptWarning: Accessed None 'Canvas'
    	myHUD UEDPIETest.TheWorld:PersistentLevel.myHUD_96
    	Function MyGame.myHUD:DrawHUD:0078
    [0025.18] ScriptWarning: Accessed None 'Canvas'
    	myHUD UEDPIETest.TheWorld:PersistentLevel.myHUD_96
    	Function MyGame.myHUD:DrawHUD:009F
    [0025.18] ScriptWarning: Attempt to assign variable through None
    	myHUD UEDPIETest.TheWorld:PersistentLevel.myHUD_96
    	Function MyGame.myHUD:DrawHUD:00B3
    [0025.18] ScriptLog: This is a call to ClientMessage:3
    [0025.18] ScriptLog: This is a call to Canvas:3
    [0025.18] ScriptWarning: Accessed None 'Canvas'

  36. #36
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    i solved it!!. i decide to use simulated function DrawHUD( HUD H ) on each class outside the hud and it worked. i post the code
    PHP Code:
    class MyHud extends MobileHUD



    event PostRender() 

        
    super.PostRender() ;
      
    DisplayConsoleMessages(); 
      





    defaultproperties 

      
          

    PHP Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    var 
    config vector PlayerLocation;
    var 
    int CurTime;
    struct SCollisionsList
    {
        var 
    vector HitLocation;
        var 
    float HitTime;
    };
    var 
    int lap;
    var array< 
    SCollisionsListCollisionsList;
    var 
    string html;
    var() 
    string MessageHud;
    var 
    bool ShowMessageHud;
    var 
    string nRand;

    simulated event PostBeginPlay(){
            
    super.PostBeginPlay();
           
        
    }
    simulated function bool CalcCamerafloat fDeltaTimeout vector out_CamLocout rotator out_CamRotout float out_FOV )
    {
         
    local vector XYZ;
        
    //this makes the camera stay with the vehicle
        
    GetActorEyesViewPointout_CamLocout_CamRot );

            
    GetAxes(Rotation,X,Y,Z);

            
    // a bit behind
            
    out_CamLoc Location 40 X;
            
    //up a bit
            
    out_CamLoc.Location.25;

        
    //camera rotation yaw = vehicle rotation yaw
        
    out_CamRot.Yaw Rotation.Yaw;
        
    //  look down a bit
        
    out_CamRot.Pitch = (-0.0f     *DegToRad) * RadToUnrRot;
        
    //delete this line if you want the cam to roll with the vehicle
        
    out_CamRot.Roll 0;

        return 
    true;
    }
    simulated function DrawHUDHUD H )
    {
        if(
    ShowMessageHud)
        {
      
    super.DrawHUD(H);
        
       
    H.Canvas.SetPos(H.Canvas.ClipX/2,H.Canvas.ClipY/2-200);  
            
    H.Canvas.SetDrawColor(255255255);  
        
    H.Canvas.Font = class'Engine'.static.GetLargeFont();  
                
                    
    H.Canvas.DrawText(MessageHud);
                }

    }
    event Touch(Actor OtherPrimitiveComponent OtherCompvector HitLocationvector HitNormal)
    {
            
    local string MetaName;
            
            
            if(
    lap==0)lap=1;
           
            
    MetaName=string(Other);
            
            
            
         switch(
    MetaName)
         {
             case (
    "TriggerVolume_0"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
            break;
             
             case (
    "TriggerVolume_1"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_2"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_3"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_4"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_5"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_6"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_7"):
             
    ShowMessageHud=false;
             break;
             
             case (
    "TriggerVolume_8"):
             
    lap++;
             
    ShowMessageHud=true;
             
    MessageHud="Vuelta Numero "$lap;
             break;
             
             case (
    "TriggerVolume_9"):
             
    ShowMessageHud=false;
             break;
             
             
         }
         
           
           
       
       
    }
    //this function generates a random number. eery lap the game increase the number lenght by one
    simulated function int  GenerateRandomNumber(int nLap)
    {
        
    local int sRandomNumber;
        
    local int nBase;
        
    local int Range1;
        
    local int Range2;
        
        
        
    nBase=3;
        
    Range1=10**(nLap+nBase-1);
        
    Range2=(10**(nLap+nBase))-1;
        
    sRandomNumber=intRandRange(Range1,Range2)); 
             
           return 
    sRandomNumber;
        
              
    }
     
    simulated event RigidBodyCollision (PrimitiveComponent HitComponentPrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collisionint ContactIndex)
     {
            
    local SCollisionsList LastCollision;
          
          
    PlayerLocation=GetALocalPlayerController().Pawn.Location;
             
    LastCollision.HitLocation  =  Collision.ContactInfos[0].ContactPosition;
    LastCollision.HitTime WorldInfo.TimeSeconds;

    CollisionsList.AddItem(LastCollision);
       
     }

    defaultproperties
    {
         
    bDirectHitWall=True;
        

    PHP Code:
    class BaseGame extends UDKGame
    var 
    SoundCue beep
    var 
    int CurTime
    var 
    bool bPlayed
    var 
    int LastTime
    var 
    bool Move
    var 
    string sMessage
    var 
    bool bShowCountDown;


    event PostLoginPlayerController NewPlayer 

        
    super.PostLogin(NewPlayer); 
          


    event Tick(float DeltaTime
    {   
         
    CurTime=WorldInfo.TimeSeconds
       if(
    CurTime==1
       {
           
    LastTime=1
           
    bShowCountDown=true;
       }
        
         
       if(
    CurTime==2
       { 
           
    sMessage="3";
           if( 
    LastTime==1
           { 
               
               
    PlaySound(beep); 
               
    LastTime=2
                
            } 
       } 
       
       if(
    CurTime==3
       { 
           
    sMessage="2";
          if( 
    LastTime==2
           { 
                
               
    PlaySound(beep); 
               
    LastTime=3
                
            } 
       } 
         
      if(
    CurTime==4
       { 
          
    sMessage="1";   
              
           if( 
    LastTime==3
           { 
               
    PlaySound(beep); 
               
    LastTime=4
                
            } 
       } 
        
      if(
    CurTime==5
       {   
      
    sMessage="Comienzo!!";     
          if( 
    LastTime==4
           { 
               
    Move=true
               
    PlaySound(beep); 
               
    PlaySound(beep); 
               
    PlaySound(beep); 
               
                
            } 
       } 
        if(
    CurTime==6
       {   
           
    bShowCountDown=false;
       } 
       
        
        

    defaultproperties 

        
        
    PlayerControllerClass=class'MyGame.MyGamePlayerController'//Your PlayerControllerClass to use with this game-type 
        
    DefaultPawnClass =class 'MyGame.MyPawn'//Your PawnClass to use with this game-type 
        
    HUDType =class 'MyGame.MyHud'//Your HUD (Heads Up Display) to use with this game-type 
        
    bDelayedStart false //If TRUE, the game will not immediately begin when the player joins. 
         
    beep=SoundCue'KismetExamples.homing_beacon_Cue'     
          
          
      

    PHP Code:
    class MyGamePlayerController extends GamePlayerController 
    var 
    BaseGame cBaseGame
         
    simulated event PostBeginPlay(){ 
            
    super.PostBeginPlay(); 
            
    cBaseGame=spawn(class'BaseGame'); 
       
         


    simulated function DrawHUDHUD H )
    {
        
    local string sText;
      
    super.DrawHUD(H);
      if(
    cBaseGame.bShowCountDown)
      {
      
    sText=cBaseGame.sMessage;
        
     
    H.Canvas.SetPos(H.Canvas.ClipX/2,H.Canvas.ClipY/2-200);  
            
    H.Canvas.SetDrawColor(255255255);  
        
    H.Canvas.Font = class'Engine'.static.GetLargeFont();  
                
                
    H.Canvas.DrawText(sText);
            }
    }
    state PlayerDriving 

       
        function 
    PlayerMovefloat DeltaTime 
        { 
            
    local float ForwardStrafe
            
    local bool bState
             
            
    bState=cBaseGame.Move
             
            
                    
         
    //if the counter gets to start! in BaseGame.uc send a message for debugging purposses 
        //this is not working. its not capturing the BaseGame.Move variable value   
            
    if(bState==true
            { 
              
            
    UpdateRotation(DeltaTime); 

            
    // Get the forward input information 
            
    Forward PlayerInput.aForward
            
    // Get the strafe input information 
            
    Strafe PlayerInput.aStrafe

                        if (
    PlayerInput != None
                        { 
                          
    Forward = (((PlayerInput.aTilt.UnrRotToDeg) - 30.f) / 50.f) * -1.f
                        } 

                    
    // Clamp the forward to within -1.f and 1.f 
                    
    Forward FClamp(Forward, -1.f1.f); 
                    
                    
    ProcessDrive(ForwardStrafePlayerInput.aUpbPressedJump); 

                       

                    
    bPressedJump false
                  
              } 
                else 
                { 
                        
    ProcessDrive(00PlayerInput.aUpbPressedJump); 

                } 
               
            } 
             


    defaultproperties
        
    bFreeLook false// to disable free look with mouse 
    bMousing false// to disable mousing 


  37. #37
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default

    now i have a new problem...lol
    i was checking the game and senf a notifier for the simulated event RigidBodyCollision well ir works but not always.
    when it has a direct hit to the wall sends a notify, but when you collide by side of the car, or when you barely touch the wall, the RigidBodyCollision event doesn't fire.

    another problem i found is that when the car crashes on a narrow space it tends to overturn and the game colapses (because the car is set to always move forward automatically), so there is a way to keep it always on the floor?
    Last edited by DonFrag; 06-11-2012 at 03:18 AM.

  38. #38
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    144

    Default

    If the car runs into another actor it calls

    Code:
    event RanInto( Actor Other )	// called for encroaching actors which successfully moved the other actor out of the way
    I got around those problems by sending both to a single function:

    Code:
    simulated event RigidBodyCollision (PrimitiveComponent HitComponent, PrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collision, int ContactIndex)
    {
    	super.RigidBodyCollision(hitcomponent, othercomponent, Collision, ContactIndex);
    	collidedWith(OtherComponent.owner);
    }
    
    event RanInto( Actor Other )	// called for encroaching actors which successfully moved the other actor out of the way
    {
    	super.RanInto(other);
    	collidedWith(other);
    }
    
    function collidedWith(Actor a) 
    { // both RigidBodyCollision and RanInto end up here
    	// My code here
    }
    As for keeping the car upright - there are some constraints that handle that within the svehicle class. Can't remember them off hand but if you have a look through the vehicle or svehicle code you should find it.

  39. #39
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default



    here i uploaded a video with the game
    as you can see when the car touch the wall sometimes doesn't call the collision function.

    this video was made before the paco suggestion, but with his solution, the effect is the same. i don't know if this happens beacase the hit box of the car, or the config for collision, etc

    im going to add this suggestion, make a video again and show it
    (thanks paco)

  40. #40
    Skaarj
    Join Date
    Apr 2012
    Location
    Quilpue, Chile
    Posts
    27
    Gamer IDs

    Gamertag: DonFrag

    Default



    as you can see not all coliisions are detected when you touch the wall
    this is the new code


    PHP Code:
    class CarPLayer extends UTVehicle_Scorpion_Content;
    var 
    config vector PlayerLocation;
    var 
    int CurTime;
    struct SCollisionsList
    {
        var 
    vector HitLocation;
        var 
    float HitTime;
        var 
    int nHits;

    };
    var 
    int lap;
    var array< 
    SCollisionsListCollisionsList;
    var 
    string html;
    var() 
    string MessageHud;
    var 
    bool ShowMessageHud;
    var 
    string nRand;
    var 
    int nHits;

    simulated event PostBeginPlay(){
            
    super.PostBeginPlay();
           
        
    }
    simulated function bool CalcCamerafloat fDeltaTimeout vector out_CamLocout rotator out_CamRotout float out_FOV )
    {
         
    local vector XYZ;
        
    //this makes the camera stay with the vehicle
        
    GetActorEyesViewPointout_CamLocout_CamRot );

            
    GetAxes(Rotation,X,Y,Z);

            
    // a bit behind
            
    out_CamLoc Location 40 X;
            
    //up a bit
            
    out_CamLoc.Location.25;

        
    //camera rotation yaw = vehicle rotation yaw
        
    out_CamRot.Yaw Rotation.Yaw;
        
    //  look down a bit
        
    out_CamRot.Pitch = (-0.0f     *DegToRad) * RadToUnrRot;
        
    //delete this line if you want the cam to roll with the vehicle
        
    out_CamRot.Roll 0;

        return 
    true;
    }
    simulated function DrawHUDHUD H )
    {
        
      
    super.DrawHUD(H);
        if(
    ShowMessageHud)
        {
       
    H.Canvas.SetPos(H.Canvas.ClipX/2,H.Canvas.ClipY/2-200);  
       
    H.Canvas.SetDrawColor(255255255);  
        
    H.Canvas.Font = class'Engine'.static.GetLargeFont();  
         
    H.Canvas.DrawText(MessageHud);
                }
     
     

    }
    event Touch(Actor OtherPrimitiveComponent OtherCompvector HitLocationvector HitNormal)
    {
            
    local string MetaName;
            
            
            if(
    lap==0)lap=1;
           
            
    MetaName=string(Other);
            
            
    // GetALocalPlayerController().ClientMessage(MetaName  );//this works 
            // `Log(MetaName);
     
            
         
    switch(MetaName)
         {
             case (
    "TriggerVolume_0"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
            break;
             
             case (
    "TriggerVolume_1"):
             
    ShowMessageHud=false;
             break;
             
             
             case (
    "TriggerVolume_11"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_12"):
             
    ShowMessageHud=false;
             break;
             
               case (
    "TriggerVolume_2"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_3"):
             
    ShowMessageHud=false;
             break;
             
             case (
    "TriggerVolume_13"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_14"):
             
    ShowMessageHud=false;
             break;
             
             case (
    "TriggerVolume_15"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_16"):
             
    ShowMessageHud=false;
             break;
             
              case (
    "TriggerVolume_4"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_5"):
             
    ShowMessageHud=false;
             break;
             
              case (
    "TriggerVolume_6"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_7"):
             
    ShowMessageHud=false;
             break;
             
              case (
    "TriggerVolume_17"):
             
    ShowMessageHud=true;
              
    MessageHud=string(GenerateRandomNumber(lap));
             break;
             
             case (
    "TriggerVolume_18"):
             
    ShowMessageHud=false;
             break;
             
             
             
             case (
    "TriggerVolume_8"):
             
    lap++;
             
    ShowMessageHud=true;
             
    MessageHud="Vuelta Numero "$lap;
             break;
             
             case (
    "TriggerVolume_9"):
             
    ShowMessageHud=false;
             break;
             
             
         }
         
           
           
       
       
    }
    //this function generates a random number. eery lap the game increase the number lenght by one
    simulated function int  GenerateRandomNumber(int nLap)
    {
        
    local int sRandomNumber;
        
    local int nBase;
        
    local int Range1;
        
    local int Range2;
        
        
        
    nBase=3;
        
    Range1=10**(nLap+nBase-1);
        
    Range2=(10**(nLap+nBase))-1;
        
    sRandomNumber=intRandRange(Range1,Range2)); 
             
           return 
    sRandomNumber;
        
              
    }

       
    simulated event RigidBodyCollision (PrimitiveComponent HitComponentPrimitiveComponent OtherComponent, const out Actor.CollisionImpactData Collisionint ContactIndex)
    {
        
    super.RigidBodyCollision(hitcomponentothercomponentCollisionContactIndex);
        
    collidedWith(OtherComponent.owner);
    }

    event RanIntoActor Other )    // called for encroaching actors which successfully moved the other actor out of the way
    {
        
    super.RanInto(other);
        
    collidedWith(other);
    }

    function 
    collidedWith(Actor a
    // both RigidBodyCollision and RanInto end up here
        // My code here
        
    local string msg;
        
        
    nHits++;
        
    msg=string(nHits);
        
        
    GetALocalPlayerController().ClientMessage("hit with:"$msg);
        
    }

    defaultproperties
    {
         
    bDirectHitWall=True;
        



 
Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.