Results 1 to 5 of 5
  1. #1
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,629
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default problem with aim and shooting

    hello i'm trying to do a side scroller game, all seems to work right, but i can't figure out on how to aim or shooting at the right direction, i have follow a few tutorial from the forums to do the aim and shooting but nothing seems to work

    here is a picture of the wrong behavior

    This Image Was Automatically Resized by using the Screenshot Tag.  Click to view the full version

    the thing is that i want to aim in the Y axis, up, down, all 360 degress, but now the aim is at the X axis, i have change some things in the code but i have altered the rotation of the pawn not for the weapon aim, here is the code of the rotation of my player controller

    Code:
    function UpdateRotation( float DeltaTime )
    {
            local Rotator DeltaRot, newRotation, ViewRotation;
    
    	local vector mousePosition;
    
    
    	mousePosition.X = MyPlayerInput(PlayerInput).deltax;
    	mousePosition.Y = MyPlayerInput(PlayerInput).deltay;
    	mousePosition.Z = 0;
    
    	NewRotation = rotator(mousePosition - Pawn.Location);
    
    
    
    	if ( Pawn != None )
    		Pawn.FaceRotation(NewRotation, deltatime);
    
    }
    
    function rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
    {
        return Rotation;
    }
    
    event PlayerTick( float DeltaTime )
    {
    		local Vector PawnXYLocation;
    		local Rotator NewRotation;
    		local vector MouseLoc;
    
            super.PlayerTick(DeltaTime);
    
            //Set the location of the 3d marker that moves with the mouse.
            //MouseCursor.SetLocation(MouseHitWorldLocation);
    
    		PawnXYLocation.X = Pawn.Location.X;
    		PawnXYLocation.Y = Pawn.Location.Y;
    		MouseLoc.X=MyPlayerInput(PlayerInput).deltax;
    		MouseLoc.Y=MyPlayerInput(PlayerInput).deltay;
    
    		NewRotation = Rotator(MouseLoc - PawnXYLocation);
    		//NewRotation.Pitch = 0.0f;
    
    		Pawn.SetRotation(NewRotation);
    }
    
    DefaultProperties
    {
    	CameraClass=class'MechCops.CustomCamera'
    	InputClass=class'MechCops.MyPlayerInput'
    }
    i'm receiving the mouse coordinates from a custom input class

    Code:
    class MyPlayerInput extends UDKPlayerInput within CustomPlayerController;
    
    var float deltax, deltay;
    
    function bool InputAxis( int ControllerId, name Key, float Delta, float DeltaTime, optional bool bGamepad )
    {
    	switch(Key)
    	{
    	case 'MouseX':
    		deltax += Delta;
    		break;
    	case 'MouseY':
    		deltay += Delta;
    		break;
    	}
    	return false;
    }
    
    DefaultProperties
    {
    	OnReceivedNativeInputAxis=InputAxis
    }
    i really need help on this, can somebody help me or tell me some advice to solve this problem?

    thanks in advance for the help.
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  2. #2
    Skaarj
    Join Date
    Dec 2010
    Location
    São Paulo - SP, Brazil
    Posts
    25

    Default

    Take a look at this page: http://udn.epicgames.com/Three/Camer...hnical%20Guide

    that page contains a great side-scrolling camera and already have the shot direction

    i'm new in UDK script yet, but I hope that can help u =D

  3. #3
    MSgt. Shooter Person
    Join Date
    Sep 2010
    Posts
    127

    Default

    Just curious have you set the crosshair to move to where the pawn is aiming?

    Code:
    class SideScrollingShootAllDirectionPawn extends UTPawn;
    
    var float CamOffsetDistance; //Position on Y-axis to lock camera to
    
    //override to make player mesh visible by default
    simulated event BecomeViewTarget( PlayerController PC )
    {
       local UTPlayerController UTPC;
    
       Super.BecomeViewTarget(PC);
    
       if (LocalPlayer(PC.Player) != None)
       {
          UTPC = UTPlayerController(PC);
          if (UTPC != None)
          {
             //set player controller to behind view and make mesh visible
             UTPC.SetBehindView(true);
             SetMeshVisibility(UTPC.bBehindView);
             UTPC.bNoCrosshair = true;
          }
       }
    }
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
       out_CamLoc = Location;
       out_CamLoc.Y = CamOffsetDistance;
    
       out_CamRot.Pitch = 0;
       out_CamRot.Yaw = 16384;
       out_CamRot.Roll = 0;
       return true;
    }
    
    simulated singular event Rotator GetBaseAimRotation()
    {
    	//local vector	POVLoc;
    	local rotator	POVRot;
    
    	// If we have a controller, by default we aim at the player's 'eyes' direction
    	// that is by default Controller.Rotation for AI, and camera (crosshair) rotation for human players.
    
    	// If we have no controller, we simply use our rotation
    	POVRot = Rotation;
    
    	// If our Pitch is 0, then use RemoveViewPitch
    	if( POVRot.Pitch == 0 )
    	{
    		POVRot.Pitch = RemoteViewPitch << 8;
    	}
    
    	return POVRot;
    }


    Code:
    Class SidescrollingShootallDirectionsPC extends UTPlayerController;
    
    state PlayerWalking
    {
    ignores SeePlayer, HearNoise, Bump;
    
       function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
       {
          local Rotator tempRot;
    
          if( Pawn == None )
          {
             return;
          }
    
          if (Role == ROLE_Authority)
          {
             // Update ViewPitch for remote clients
             Pawn.SetRemoteViewPitch( Rotation.Pitch );
          }
    
          Pawn.Acceleration.X = -1 * PlayerInput.aStrafe * DeltaTime * 100 * PlayerInput.MoveForwardSpeed;
          Pawn.Acceleration.Y = 0;
          Pawn.Acceleration.Z = 0;
          
          tempRot.Pitch = Pawn.Rotation.Pitch;
          tempRot.Roll = 0;
          if(Normal(Pawn.Acceleration) Dot Vect(1,0,0) > 0)
          {
             tempRot.Yaw = 0;
             Pawn.SetRotation(tempRot);
          }
          else if(Normal(Pawn.Acceleration) Dot Vect(1,0,0) < 0)
          {
             tempRot.Yaw = 32768;
             Pawn.SetRotation(tempRot);
          }
    
          CheckJumpOrDuck();
       }
    }

    I have not used your codes at all because it required your custom classes and It was much easier to debug using these codes instead. This should be what your looking for though I had no idea how to do this myself as of 15-20minutes ago I worked out how to do it through trial and error and tracing back functions to what they do originally before side scrolling.
    Last edited by astrolite; 12-08-2010 at 07:56 PM.

  4. #4
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,629
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    thanks astrolite, the code work perfect, i have another question, my crosshair does not moves, what i need to do, to get the crosshair update with the mouse movement ?
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  5. #5
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,629
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    all was working ok, i have used in the first time the september beta, now i have moved the scripts to the november beta, now the scroll and the aim work perfect but the weapon is no showing up, any ideas ?
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!


 

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.