Jump to content

#code

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by #code

  1. I change script:

    Script.TireMass = 5
    Script.SpringForce = 1000
    function Script:Start()
    	self.Wheels={}
    	self.Wheels[0]=self.entity:FindChild("WheelFL")
    	self.Wheels[1]=self.entity:FindChild("WheelFR")
    	self.Wheels[2]=self.entity:FindChild("WheelRL")
    	self.Wheels[3]=self.entity:FindChild("WheelRR")
    	self.Amortisseurs={}
    	self.Axis={}
    	self.SecondAxis={}
    	for n=0,3 do
    		pos=self.Wheels[n]:GetPosition(true)
    		self.Axis[n]=Pivot:Create(self.entity)--
    		self.Axis[n]:SetPosition(pos, true)
    		axe=Vec3(0, 1, 0)
    		self.Amortisseurs[n]=Joint:Slider(pos.x, pos.y, pos.z, axe.x,axe.y,axe.z, self.Axis[n], self.entity)
    		self.Amortisseurs[n]:EnableLimits()
    		self.Amortisseurs[n]:SetLimits(-1,1)
    		self.Amortisseurs[n]:SetSpring(self.SpringForce,0.25,5)
    	end
    	self.Volants={}
    	for n=0,1 do
    		axe=Vec3(0, 1, 0)
    		self.SecondAxis[n] = Pivot:Create(self.Axis[n])--
    		pos=self.Wheels[n]:GetPosition(true)
    		self.SecondAxis[n]:SetPosition(pos, true)
    		self.Volants[n]=Joint:Hinge(pos.x, pos.y, pos.z, axe.x,axe.y,axe.z, self.SecondAxis[n], self.Axis[n])
    		self.Volants[n]:EnableLimits() 
    		self.Volants[n]:SetLimits(-30,30)
    		self.Volants[n]:SetMotorSpeed(200)
    		self.Volants[n]:EnableMotor() 
    		self.Volants[n]:SetAngle(0)
    	end
    	for n=2,3 do
    		pos=self.Wheels[n]:GetPosition(true)
    		axe=Vec3(1, 0, 0)
    		self.Volants[n]=Joint:Hinge(pos.x, pos.y, pos.z, axe.x,axe.y,axe.z, self.Wheels[n], self.Axis[n])
    		self.Volants[n]:EnableLimits() 
    		self.Volants[n]:SetLimits(-30,30)
    		self.Volants[n]:SetMotorSpeed(200)
    		self.Volants[n]:EnableMotor() 
    		self.Volants[n]:SetAngle(0)
    	end
    	self.ThirdAxis={}
    	for n=0,1 do
    		pos=self.Wheels[n]:GetPosition(true)
    		axe=Vec3(1, 0, 0)
    		self.ThirdAxis[n]=Joint:Hinge(pos.x, pos.y, pos.z, axe.x,axe.y,axe.z, self.Wheels[n], self.SecondAxis[n])
    		self.ThirdAxis[n]:EnableLimits() 
    		self.ThirdAxis[n]:SetLimits(-30,30)
    		self.ThirdAxis[n]:SetMotorSpeed(200)
    		self.ThirdAxis[n]:EnableMotor() 
    		self.ThirdAxis[n]:SetAngle(0)
    	end
    end
    
    
    --[[
    function Script:UpdateWorld()
    	
    end
    ]]
    
    
    function Script:UpdatePhysics()
    end
    
    
    --[[
    --This can be used to select which objects an entity collides with.  This overrides collision types completely.
    function Script:Overlap(e)
    	return Collision:Collide
    end
    ]]
    
    --[[
    function Script:Collision(entity, position, normal, speed)
    	
    end
    ]]
    
    --[[
    function Script:Draw()
    	
    end
    ]]
    
    --[[
    function Script:DrawEach(camera)
    	
    end
    ]]
    
    
    --This function will be called after the world is rendered, before the screen is refreshed.
    --Use this to perform any 2D drawing you want the entity to display.
    function Script:PostRender(context)
    
    end
    
    
    --[[
    --This function will be called when the entity is deleted.
    function Script:Detach()
    	
    end
    ]]
    
    --[[
    --This function will be called when the last instance of this script is deleted.
    function Script:Cleanup()
    	
    end
    ]]
    
    --[[
    --This function will be called upon completion of a one-shot animation played with the PlayAnimation() command.
    function Script:EndAnimation(sequence)
    	
    end
    ]]

    But nothing happens.

    MyCar.rar

  2. Hello, it's me again. And I'm trying to make joint: Slider shock absorbers. But something goes wrong, and I can not understand that. Please explain how this works. I need the car to fall to the ground and spin the shock absorbers.

    Code in RaceCar.lua:

    Script.TireMass = 20
    Script.SpringForce = 1000
    function Script:Start()
    	self.Wheels={}
    	self.Wheels[0]=self.entity:FindChild("WheelFL")
    	self.Wheels[1]=self.entity:FindChild("WheelFR")
    	self.Wheels[2]=self.entity:FindChild("WheelRL")
    	self.Wheels[3]=self.entity:FindChild("WheelRR")
    	self.Axes={}
    	for n=0,3 do 
    		self.Axes[n]=Pivot:Create()
    		self.Axes[n]:SetPosition(self.Wheels[n]:GetPosition())
    		self.Axes[n]:SetMass(self.TireMass)
    	end
    	self.Directions={}
    	for n = 0, 1 do
    		self.Directions[n]=Pivot:Create(self.Axes[n])
    		self.Directions[n]:SetPosition(self.Axes[n]:GetPosition())
    	end
    	for n=2,3 do
    		self.Wheels[n]:SetParent(self.Axes[n])
    	end
    	for n=0,1 do
    		self.Wheels[n]:SetParent(self.Directions[n])
    	end
    	for n=0,3 do
    		pos=self.Axes[n]:GetPosition(true)
    		axe=Vec3(0, 1, 0)
    		self.Amortisseurs={}
    		self.Amortisseurs[n]=Joint:Slider(pos.x, pos.y, pos.z, axe.x,axe.y,axe.z, self.Axes[n], self.entity)
    		self.Amortisseurs[n]:EnableLimits()
    		self.Amortisseurs[n]:SetLimits(-1,1)
    		self.Amortisseurs[n]:SetSpring(self.SpringForce,0.25,5)
    	end
    	
    end

    And video:

  3. I think I know what the problem is, but I don't know how to solve it. First, you need to remove the bridge in the corner of the map, because it is not completed. But it's not about him. If you remove it, then the following happens: when I press the space bar (handbrake), the car starts to skid, and when it starts to fall the game crashes. What to do? Is this a known issue?

  4. Hi.

    I want to make a managed vehicle, but found no examples other than what lies in the REFERENCE API. Please tell me how to implement it if I have an FBX model with a body and four separate wheels.

×
×
  • Create New...