Jump to content

Recommended Posts

Posted

Hello all,

 

I am having a go at vehicles again, and unfortunately I lost my old project files, so I am starting from scratch, yet one thing in blocking me.

 

When i press A or D to turn the wheels left or right, they stay there and I am having trouble getting a working way of making them turn back. I have looked at the driver.lua file, and that's what I am basing it off, yet it does not seem to work. Here is my code.

 

// Steering
	 if (KeyDown(KEY_A) && (steerangle<=40.0f)) {
steerangle+=0.7f;
SetSteerAngle(veh, steerangle, 0);
SetSteerAngle(veh, steerangle, 1);
} else {
if(!KeyDown(KEY_A) && (steerangle>0)){
 if(steerangle>0){
 steerangle=steerangle-4.0*AppSpeed();
 }
}
}


	 if (KeyDown(KEY_D) && (steerangle>=-40.0f)) {
steerangle-=1.0f;
SetSteerAngle(veh, steerangle, 0);
SetSteerAngle(veh, steerangle, 1);
} else {
if(steerangle<0){
 steerangle=steerangle+4.0*AppSpeed();
}
}

I had done this once before, but forgot.

Can anyone give me some pointers to get this working?

 

Thanks in advance,

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Posted

Hi ithink you miss some lines i did :

 

steerangle=Clamp(steerangle,-25,25) --25 here max angle
    car:SetSteerAngle(steerangle,0)
    car:SetSteerAngle(steerangle,1)

 

hopeit was what you look for

AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11

Posted

Thanks! That worked like a charm :)

 

I must have missed needing to update the wheels to the angles.

 

Thanks again :)

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...