Jump to content
  • entries
    39
  • comments
    81
  • views
    12,960

Monster truck & speed car demo - nice Physics LE4.5


Marcousik

2,770 views

 Share

 

That's just monster truck fun - This driving/vehicle physics is (well I think) definitivly better than 4.3 ?

 

 

Here is a speed car with speed boooosst feature ;) (max 50 m/s)

 

  • Like 3
 Share

5 Comments


Recommended Comments

 

 

My forklift doesn't go up this ramp. Any suggestions, my friend?

 

-- Script Spring.

Script.chassis = nil --entity "Chassis"
Script.llanta  = nil --entity "Llanta"



--Spring	
local suspension
-- motor
local motor



function Script:Start()
	
	
	--Slider. 
	suspension = Joint:Slider(self.entity:GetPosition().x, self.entity:GetPosition().y, self.entity:GetPosition().z, 0, 1, 0, self.entity, self.chassis )  
	suspension:EnableLimits()
	suspension:SetLimits(-0.01,-0.05 )
	
	--Hinge. 
	motor = Joint:Hinge( self.llanta:GetPosition().x, self.llanta:GetPosition().y, self.llanta:GetPosition().z, 0, 0, 1, self.llanta, self.entity ) 
	motor:DisableLimits()
	
	self.llanta:SetFriction(1000, 1000 ) 
	
end



function Script:UpdateWorld()

   --if self.entity:GetKeyValue("type", "Suspension0") == "Suspension0" then 
	
	
	
		motor:SetAngle( motor:GetAngle()-100) 
	
		motor:EnableMotor()
		motor:SetMotorSpeed(100000000)
	--end 
	
end




 

image.thumb.png.9bd2ab9c294bfef30605584482f10243.png

Link to comment

Hey Yue, What I would change:

1) SetFriction(10,10) should be enough

2) What are the mass of tires and car you used ? -> make them to script properties so you can change and test them quickly

3) Why don't you use:

	self.suspensionJoint:SetTargetAngle(0)	--at the middle
		self.suspensionJoint:SetMotorSpeed(1)	-- 1 m/s
		self.suspensionJoint:SetStrength(100)	--defatul is 1000
		self.suspensionJoint:EnableMotor()

for your suspensions -> slider joints.

4) that is too much:

motor:SetMotorSpeed(100000000)

I would set it to max 5000 to begin

5) As Josh said, you can't make it climb if the speed is constant, so you have to make this too:

if App.window:KeyDown(Key.Up) then
			self.currspeed = self.currspeed + 10
			if self.currspeed>self.motorspeed then
				self.currspeed=self.motorspeed
			end
			if self.currspeed == 10 then self.wheelJoint:EnableMotor() end
			self.wheelJoint:SetMotorSpeed(self.currspeed)
			
		end
		if App.window:KeyDown(Key.Down) then
			self.currspeed = self.currspeed - 10
			if self.currspeed<-self.motorspeed then
				self.currspeed=-self.motorspeed
			end
			self.wheelJoint:SetMotorSpeed(self.currspeed)
		end

 

6) Try simply this script: (it is really ok - why not?) and try to change the values so you will learn the car's behavior:

 

 

 

 

Link to comment
function Script:Start()
	
	--Slider. 
	suspension = Joint:Slider(self.entity:GetPosition().x, self.entity:GetPosition().y, self.entity:GetPosition().z, 0, 1, 0, self.entity, self.chassis )  
	--suspension:EnableLimits() NO!!!
	--suspension:SetLimits(-0.01,-0.05 ) NO!!!
  	suspension->SetSpring(200); --YES!

Don't use slider limits, use a spring. You will need to experiment with the spring value.

You could also try enabling swept collision on the tires, it might make things smoother.

  • Like 1
Link to comment

 

It's unfortunate, this doesn't work for me, it doesn't go up the inclined ramp. 

-- Script Spring.

Script.chassis = nil --entity "Chassis"
Script.llanta  = nil --entity "Llanta"



--Spring	
local suspension
-- motor
local motor


local vel = 0 
function Script:Start()
	
	
	--Slider. 
	suspension = Joint:Slider(self.entity:GetPosition().x, self.entity:GetPosition().y, self.entity:GetPosition().z, 0, 1, 0, self.entity, self.chassis )  
	--suspension:EnableLimits()
	--suspension:SetLimits(-0.01,-0.05 )
	suspension:SetSpring(200)
	--suspension:EnableMotor()
	
	

	
	
	--Hinge. 
	motor = Joint:Hinge( self.llanta:GetPosition().x, self.llanta:GetPosition().y, self.llanta:GetPosition().z, 0, 0, 1, self.llanta, self.entity ) 
	motor:DisableLimits()
	
	self.llanta:SetFriction(10, 10 ) 
	
end



function Script:UpdateWorld()

   
	motor:SetAngle( motor:GetAngle() - 100 )
   
	vel = vel + 100 
	
	
	
	motor:EnableMotor()
	motor:SetMotorSpeed( vel ) 
		

	
end

 

Link to comment
Guest
Add a comment...

×   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...