Announcement
Collapse
No announcement yet.
Relative Physics Problem
Collapse
X
-
chrisCPO repliedHey thanks that helped me out a ton, got it working how I want it too, well at least with the Axis constraints.
-
Hiredicespecter replied@chrisCPO: I see possible options for you. You could use the SimObject of the Cicada and tweak its values. That might work for you or not depending on what movement behavior you want. In this case you would not use most of the code in this thread.^^
The second option is to use the code posted here and set bStayUpright=true in the DefaultProperties. This will make UDK attach a invisible spring to your vehicle to keep it upright. You probably should try that first. The variables StayUprightRollResistAngle, StayUprightPitchResistAngle, StayUprightStiffness, StayUprightDamping allow you to fine tune that spring.
If that doesn't result in what you want, you can use angular RB_Constraints.
Leave a comment:
-
chrisCPO repliedHey I stumbled upon this thread a few days a go it has helped me out, as I am new to programming.
@spector did you ever solve the counter rotation of your vehicle. I slowly working on a hovercraft/chopter. It is a limited flight sim, flies like a jet that could hover but the craft would not be able to do loops and I want to limit the pitch and roll axis by applying a counter force if rotation.axis > or < desired rotation also I would like to keep to have the roll return to zero when the player lets off the controls, however I have tried some things none have worked.
Leave a comment:
-
Hiredicespecter repliedCurrently I'm trying to figure out how to smoothly rotate a spaceship/vehicle.
The way to rotate the spaceship/plane that I've posted before is not very UT/UDK like and doesn't allow for bots/AI and auto pilot so I'm trying a different approach.
I've started a separate thread, because the discussion proably will be longer.
Leave a comment:
-
ScriptingScrub repliedOriginally posted by deguitz06 View Postany code for that? i dont know how to do it...
Leave a comment:
-
elhant1 repliedI also would like to change my rolling movement to another key since my vehicle rolls with my mouse movement making it hard to control.
Leave a comment:
-
deguitz06 repliedmouse wheel? i don't know how lol.
and which movement do i use with the wheel?
Leave a comment:
-
elhant1 repliedMaybe you can use the wheel ?
For strafing i don't know what is the name of the variable.
Leave a comment:
-
deguitz06 repliedOriginally posted by elhant1 View Post@deguitz06 I'm happy for you.
An idea for my problem : I changed my ship 3d mesh but now he can't move.
I have a bone and a view socket but no anim set
EDIT: It works. Thanks for the code!
@deguitz06
Nice code. I like your forward/backward system.
I would like to use it but i keep the classic input systems.
An idea for how to do that with keeping the roll?
Actually, forward and backward does not work on me when i add pitch and rolling. I think there has to be a way to set those movements separately.
My vehicle pitches down when i move forward making a loop. I also would like to change my rolling movement to another key since my vehicle rolls with my mouse movement making it hard to control. I'd like take out those strafing movements with yawing movements to make my vehicle controllable too. So yeah, if anyone has solutions for those please help me >.>
Thanks again
Leave a comment:
-
elhant1 replied@deguitz06 I'm happy for you.
An idea for my problem : I changed my ship 3d mesh but now he can't move.
I have a bone and a view socket but no anim set
EDIT: It works. Thanks for the code!
@deguitz06
Nice code. I like your forward/backward system.
I would like to use it but i keep the classic input systems.
An idea for how to do that with keeping the roll?
Leave a comment:
-
deguitz06 repliedOriginally posted by deguitz06 View PostOk, I'll try to replace PZ with AR, and see if it works....
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 AR_ForceRotationVectX *= 800 * Rise; // PZ_NewRise is between -1 and 1 // 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; 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 just want to use my mouse to make the camera look around the vehicle surroundings, and make the vehicle roll, pitch, and yaw without moving the camera since I'm not moving the mouse yet. Is that possible guys?
EDIT:
Rolling and pitching seems to work now. I just changed the values of the rolltorquestrafefactor, rolltorqueturnfactor, and rolltorquemax since my spaceship is quite big and heavy, i thought that i needed more force to make it move just like the thrustforce. I added more rolldamping to make it controllable and not rolling too much.
This is my vehicle.uc now:
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 AR_ForceRotationVectX *= 800 * Rise; // PZ_NewRise is between -1 and 1 // 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; 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=300000.0 MaxReverseForce=20000.0 LongDamping=0.1 MaxStrafeForce=0.0 LatDamping=0.7 MaxRiseForce=1000000.0 UpDamping=0.0 TurnTorqueFactor=700000.0 TurnTorqueMax=1000000.0 TurnDamping=100 MaxYawRate=3.8 PitchTorqueFactor=50000.0 PitchTorqueMax=100000.0 PitchDamping=0.3 RollTorqueTurnFactor=50000.0 RollTorqueStrafeFactor=1000.0 RollTorqueMax=100000.0 RollDamping=2 MaxRandForce=00.0 RandForceInterval=1.5 StopThreshold=100 bShouldCutThrustMaxOnImpact=true PitchViewCorrelation=9999.0 bAllowZThrust=True End Object SimObj=SimObject Components.Add(SimObject) bAutoLand=true ContrailColorParameterName=ContrailColor bHomingTarget=true bNoZDampingInAir=false bReducedFallingCollisionDamage=true bCanStrafe=true bCanFly=true bTurnInPlace=true bFollowLookDir=true bDriverHoldsFlag=false bCanCarryFlag=false LookForwardDist=100.0 IconCoords=(U=989,V=24,UL=43,VL=48) bEjectPassengersWhenFlipped=false bMustBeUpright=false UpsideDownDamagePerSec=0.0 bDropDetailWhenDriving=true bFindGroundExit=false //@todo: it would be nice if the alternate path code would count being in a VolumePathNode above the intended alternate path bUseAlternatePaths=false bJostleWhileDriving=true bFloatWhenDriven=true }
It still rolls and pitches as the camera also moves.... can i change these movement and assign it to other keys like the arow buttons? My vehicle does not move forward too. Spacebar still makes my vehicle go up and C still makes it go down. Maybe make the vehicle forward with W, Slowdown or stop by S, yaw by using keys A and D, rolling and pitching movements by using the arrow keys, and camera movements by moving the mouse.
So now, my vehicle goes up, down, roll, pitch, no yawing ,forward and backward movements yet. Any ideas on how to do this guys? Thanks
Leave a comment:
-
deguitz06 repliedOriginally posted by elhant1 View PostOk. 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:
-
deguitz06 repliedOriginally posted by Hiredicespecter View PostThe 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;
A good UnrealScript tutorial can be found here: http://www.4r7w4re.com/
Leave a comment:
-
elhant1 repliedlocal 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;
only AR you have don't change to PZ ?
Leave a comment:
Leave a comment: