Announcement

Collapse
No announcement yet.

Relative Physics Problem

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

  • replied
    Ok. I have no idea to fix it but I think I have another idea. In the Defaultinput try to change the bindings to link mouse input to gbaduck,jump,strateleft,strateright...
    I'm not sure if it's what you want and if it's possible.

    No idea for my problem?

    Leave a comment:


  • replied
    Well, if you don't have a valid declaration for a variable or it's not in the right scope, US's compiler, like most languages' can't find them and will give you errors and abort immediately.

    Where have you declared variables PZ_Force* ? Post that part of your code.

    Leave a comment:


  • replied
    @elhant1

    if i separate the following PZ commands for the roll pitch and yaw, UDK will read them as bad expressions.
    Code:
    class UTVehicle_SpaceShip extends UTAirVehicle;
    
    /* etc */ 
    
    var float AR_MaxLift, AR_TurnSpeed, AR_Speed, AR_CurrentForward, AR_AddedLiftSpeed, AR_Acceleration;
    
    /* etc */
    
    simulated function AirRaidKinematics(float DeltaTime)
    {
    	local Vector AR_ForceApplication, AR_ForceRotation, AR_ForwardsNormal, AR_UpwardsNormal, AR_SidewardsNormal;
    	local Vector AR_ForceRotationVectX, AR_ForceRotationVectY, AR_ForceRotationVectZ;
    	local float AR_Lift, AR_ForwardSpeed, AR_NewRise;
    
    	// While there is a player in the biplane:
    	if (PlayerController(Controller) != None)
    	{
    		GetAxes(Rotation, AR_ForwardsNormal, AR_SidewardsNormal, AR_UpwardsNormal);
    		
    		// Roll 
    PZ_ForceRotationVectX *= 800 * Rise; // PZ_NewRise is between -1 and 1
    
    		// Pitch 
    PZ_ForceRotationVectY *= 30 * -PlayerController(Controller).PlayerInput.aMouseY / 100;
    
    		// Yaw 
    PZ_ForceRotationVectZ *= 30 * PlayerController(Controller).PlayerInput.aMouseX / 100;
    
    		// The magic happens here ---- Forward 
    PZ_ForceApplication = PZ_ForwardsNormal * Throttle * 6000;
    
    		AR_CurrentForward += AR_Acceleration * Throttle;
    		AR_ForwardSpeed = AR_CurrentForward * 2.2;
    		// AR_ForwardSpeed is not necessarily true - I'd optimally need to use some 
    		// calculation based off Velocity and current forwards direction Vector...
    
    		// Calculate lift for the biplane:
    		AR_Lift = (AR_ForwardSpeed + AR_AddedLiftSpeed) * Abs(Cos(Rotation.Pitch));
    		if (AR_Lift > AR_MaxLift) AR_Lift = AR_MaxLift;
    		
    		// This gives lift upwards relative to its up-axis and push forwards relative to its forward-axis:
    		AR_ForceApplication.X = AR_UpwardsNormal.X * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.X;
    		AR_ForceApplication.Y = AR_UpwardsNormal.Y * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.Y;
    		AR_ForceApplication.Z = AR_UpwardsNormal.Z * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.Z;
    		
    		// Add forces and rotations
    		Mesh.AddForce(AR_ForceApplication);
    		Mesh.AddTorque(AR_ForceRotation);
    
    	}
    	else
    	{
    		AR_CurrentForward = AR_Speed; // Biplane propellor thrust sets to default
    	}
    }
    
    
    simulated function Tick(float DeltaTime)
    {
    	AirRaidKinematics(DeltaTime);
    	Super.Tick(DeltaTime);
    }
    
    /* etc */
    defaultproperties
    {
    	Begin Object Class=UDKVehicleSimChopper Name=SimObject
    		MaxThrustForce=700.0
    		MaxReverseForce=700.0
    		LongDamping=0.6
    		MaxStrafeForce=680.0
    		LatDamping=0.7
    		MaxRiseForce=1000.0
    		UpDamping=0.7
    		TurnTorqueFactor=7000.0
    		TurnTorqueMax=10000.0
    		TurnDamping=1.2
    		MaxYawRate=1.8
    		PitchTorqueFactor=450.0
    		PitchTorqueMax=60.0
    		PitchDamping=0.3
    		RollTorqueTurnFactor=700.0
    		RollTorqueStrafeFactor=100.0
    		RollTorqueMax=300.0
    		RollDamping=0.1
    		MaxRandForce=30.0
    		RandForceInterval=0.5
    		StopThreshold=100
    		bShouldCutThrustMaxOnImpact=true
    	End Object
    	SimObj=SimObject
    	Components.Add(SimObject)
    
    	COMOffset=(X=-40,Z=-50.0)
    
    	BaseEyeheight=30
    	Eyeheight=30
    	bRotateCameraUnderVehicle=false
    	CameraLag=0.05
    	LookForwardDist=290.0
    	bLimitCameraZLookingUp=true
    
    	AirSpeed=2000.0
    	GroundSpeed=1600.0
    
    	UprightLiftStrength=30.0
    	UprightTorqueStrength=30.0
    
    	bStayUpright=true
    	StayUprightRollResistAngle=5.0
    	StayUprightPitchResistAngle=5.0
    	StayUprightStiffness=1200
    	StayUprightDamping=20
    	
    	bRollToDesired = true // ## VITAL CODE: enables rolling of the pawn
    	AirSpeed = 380.0 // maximum speed
    	AccelRate = 800.0 // acceleration speed
    
    	SpawnRadius=180.0
    	RespawnTime=45.0
    
    	bOverrideAVRiLLocks=true
    
    	PushForce=50000.0
    	HUDExtent=140.0
    
    	HornIndex=0
    }
    I dont see anything wrong with this now but UDK still doesnt read these codes correctly. The PZ commands always shows up as bad expression..
    Maybe you could suggest a better coding for my vehicle.uc? maybe i should delete some of those? And yes, its for the mouse.

    Leave a comment:


  • replied
    The lines with PZ_ should start with AR_, because you have not declared any variable whose name starts with PZ_. The code pieces in this thread aren't taken from the same code base, sorry about that.

    Code:
    // Roll 
    AR_ForceRotationVectX *= 800 * Rise;
    
    // Pitch 
    AR_ForceRotationVectY *= 30 * -PlayerController(Controller).PlayerInput.aMouseY / 100;
    
    // Yaw 
    AR_ForceRotationVectZ *= 30 * PlayerController(Controller).PlayerInput.aMouseX / 100;
    
    // The magic happens here ---- Forward 
    AR_ForceApplication = AR_ForwardsNormal * Throttle * 6000;
    The PZ_ lines are supposed to replace the matching lines the AR_.

    A good UnrealScript tutorial can be found here: http://www.4r7w4re.com/

    Leave a comment:


  • replied
    @deguitz06
    Your roll pitch and yaw are in commentary.
    It's for mouse?

    @tegleg
    Any tutorial for plane !
    I think is not the same thing.
    The vehicle just can't move the view and the weapons work.

    Leave a comment:


  • replied
    Originally posted by Hiredicespecter View Post
    Jump and crouch are used for rolling,
    rotation is done with mouse
    adn forward and backward, well do just that or act as accelerate and break.

    "Bad command or expression" means that the compiler does not know what PZ_ForceApplication is. Perhaps a typo, perhaps are you missing its declaration or you're using a different name.
    So can you tell me how can i use those PZ codes? Cause I can't get them working >.> Jumping still makes my ship go up as crouching still makes my ship descend... I think there is something wrong with my vehicle.uc

    here's my vehicle.uc


    Code:
    class UTVehicle_SpaceShip extends UTAirVehicle;
    
    /* etc */ 
    
    var float AR_MaxLift, AR_TurnSpeed, AR_Speed, AR_CurrentForward, AR_AddedLiftSpeed, AR_Acceleration;
    
    /* etc */
    
    simulated function AirRaidKinematics(float DeltaTime)
    {
    	local Vector AR_ForceApplication, AR_ForceRotation, AR_ForwardsNormal, AR_UpwardsNormal, AR_SidewardsNormal;
    	local Vector AR_ForceRotationVectX, AR_ForceRotationVectY, AR_ForceRotationVectZ;
    	local float AR_Lift, AR_ForwardSpeed, AR_NewRise;
    
    	// While there is a player in the biplane:
    	if (PlayerController(Controller) != None)
    	{
    		GetAxes(Rotation, AR_ForwardsNormal, AR_SidewardsNormal, AR_UpwardsNormal);
    		
    		// Roll PZ_ForceRotationVectX *= 800 * Rise; // PZ_NewRise is between -1 and 1
    
    		// Pitch PZ_ForceRotationVectY *= 30 * -PlayerController(Controller).PlayerInput.aMouseY / 100;
    
    		// Yaw PZ_ForceRotationVectZ *= 30 * PlayerController(Controller).PlayerInput.aMouseX / 100;
    
    		// The magic happens here ---- Forward PZ_ForceApplication = PZ_ForwardsNormal * Throttle * 6000;
    
    		AR_CurrentForward += AR_Acceleration * Throttle;
    		AR_ForwardSpeed = AR_CurrentForward * 2.2;
    		// AR_ForwardSpeed is not necessarily true - I'd optimally need to use some 
    		// calculation based off Velocity and current forwards direction Vector...
    
    		// Calculate lift for the biplane:
    		AR_Lift = (AR_ForwardSpeed + AR_AddedLiftSpeed) * Abs(Cos(Rotation.Pitch));
    		if (AR_Lift > AR_MaxLift) AR_Lift = AR_MaxLift;
    		
    		// This gives lift upwards relative to its up-axis and push forwards relative to its forward-axis:
    		AR_ForceApplication.X = AR_UpwardsNormal.X * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.X;
    		AR_ForceApplication.Y = AR_UpwardsNormal.Y * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.Y;
    		AR_ForceApplication.Z = AR_UpwardsNormal.Z * AR_Lift + AR_CurrentForward * AR_ForwardsNormal.Z;
    		
    		// Add forces and rotations
    		Mesh.AddForce(AR_ForceApplication);
    		Mesh.AddTorque(AR_ForceRotation);
    
    	}
    	else
    	{
    		AR_CurrentForward = AR_Speed; // Biplane propellor thrust sets to default
    	}
    }
    
    
    simulated function Tick(float DeltaTime)
    {
    	AirRaidKinematics(DeltaTime);
    	Super.Tick(DeltaTime);
    }
    
    /* etc */
    defaultproperties
    {
    	Begin Object Class=UDKVehicleSimChopper Name=SimObject
    		MaxThrustForce=700.0
    		MaxReverseForce=700.0
    		LongDamping=0.6
    		MaxStrafeForce=680.0
    		LatDamping=0.7
    		MaxRiseForce=1000.0
    		UpDamping=0.7
    		TurnTorqueFactor=7000.0
    		TurnTorqueMax=10000.0
    		TurnDamping=1.2
    		MaxYawRate=1.8
    		PitchTorqueFactor=450.0
    		PitchTorqueMax=60.0
    		PitchDamping=0.3
    		RollTorqueTurnFactor=700.0
    		RollTorqueStrafeFactor=100.0
    		RollTorqueMax=300.0
    		RollDamping=0.1
    		MaxRandForce=30.0
    		RandForceInterval=0.5
    		StopThreshold=100
    		bShouldCutThrustMaxOnImpact=true
    	End Object
    	SimObj=SimObject
    	Components.Add(SimObject)
    
    	COMOffset=(X=-40,Z=-50.0)
    
    	BaseEyeheight=30
    	Eyeheight=30
    	bRotateCameraUnderVehicle=false
    	CameraLag=0.05
    	LookForwardDist=290.0
    	bLimitCameraZLookingUp=true
    
    	AirSpeed=2000.0
    	GroundSpeed=1600.0
    
    	UprightLiftStrength=30.0
    	UprightTorqueStrength=30.0
    
    	bStayUpright=true
    	StayUprightRollResistAngle=5.0
    	StayUprightPitchResistAngle=5.0
    	StayUprightStiffness=1200
    	StayUprightDamping=20
    	
    	bRollToDesired = true // ## VITAL CODE: enables rolling of the pawn
    	AirSpeed = 380.0 // maximum speed
    	AccelRate = 800.0 // acceleration speed
    
    	SpawnRadius=180.0
    	RespawnTime=45.0
    
    	bOverrideAVRiLLocks=true
    
    	PushForce=50000.0
    	HUDExtent=140.0
    
    	HornIndex=0
    }

    Leave a comment:


  • replied
    Jump and crouch are used for rolling,
    rotation is done with mouse
    adn forward and backward, well do just that or act as accelerate and break.

    "Bad command or expression" means that the compiler does not know what PZ_ForceApplication is. Perhaps a typo, perhaps are you missing its declaration or you're using a different name.

    Leave a comment:


  • replied
    So what key bindings have been used here? Is this the default one?


    The PZ_ForceApplication shows up as a Bad command or expression... any thoughts on this?

    Leave a comment:


  • replied
    http://www.google.co.uk/#output=sear...w=1440&bih=730

    Leave a comment:


  • replied
    I can't find.
    I think that with your experience you can help me, right?
    Thanks.

    Leave a comment:


  • replied
    @elhant1: The root bone does not need a special name. Search for some vehicle tutorials, they should have the solution.

    @deguitz06:

    The code posted earlier in this thread shows how you rolling of a ship is done.

    Originally posted by Hiredicespecter View Post
    I suggest that you use the mouse for turning to free keys. The following code will ONLY work in single player.

    Code:
    // Roll
    PZ_ForceRotationVectX *= 800 * Rise; // PZ_NewRise is between -1 and 1
    
    // Pitch
    PZ_ForceRotationVectY *= 30 * -PlayerController(Controller).PlayerInput.aMouseY / 100;
    
    // Yaw
    PZ_ForceRotationVectZ *= 30 * PlayerController(Controller).PlayerInput.aMouseX / 100;
    
    // The magic happens here ---- Forward
    PZ_ForceApplication = PZ_ForwardsNormal * Throttle * 6000;
    This plane will turn with the mouse.
    You will have to keep W pressed to move forward.

    You might try instead:
    Code:
    PZ_ForceApplication = PZ_ForwardsNormal * (Throttle+1) * 6000;
    This should result in a default forward movement, W acts as an afterbruner, A as brakes. Similiar to Ubisoft's HAWX.

    Since Steering is unused now, you might want to add strafing.

    Leave a comment:


  • replied
    Just uncommentary this:

    // AR_ForceRotationVectX *= 35 * -AR_NewRise; // AR_NewRise is between -1 and 1

    to this

    AR_ForceRotationVectX *= 35 * -AR_NewRise;

    And use espace and c

    Leave a comment:


  • replied
    hello everyone, i know i am kinda late to post in this thread but, i really need some help here..... I used the codes you guys have posted above and it works pretty well. What i want to know is how can i add rolling to my vehicle? Something like banking or doing some barrel rolls and the like. I was reading through some UDK documentations but i cant really get rolling working.... I'm kinda working on a game that is inspired by the upcoming game star citizen. I know it is hard but i just want to know how rotation can be added to my spaceship.

    Thanks in advance!

    Leave a comment:


  • replied
    Thanks for help.
    I have no problem with the view, I have not forgotten the viewsocket.
    My viper is attached to a root bone. Maybe a special name? My bone is called Viper_Mk_2.

    Leave a comment:


  • replied
    Is the mesh of the Viper attached to a root bone? Have you a socket called ViewSocket?

    Leave a comment:

Working...
X