Jump to content

Change Drive.lua vehicle to any other doesnt work?


Andy Gilbert
 Share

Recommended Posts

Im trying to impliment my own car, but when ever i change the drive.lua game script to another (e.g. the included monster truck) when i "play" the truck appears in front of me and that it, it doesnt fall to the ground and let me drive, or do anythine just the mouse look works.

 

Change this back to viperscout and works fine?

 

Anyone have any idea why?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

HI Pixel, you have thrown me there? the viperscout code is the same, and the monstertruck has a phy file?

 

Is there something else needed?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

The key word that Pixel used is "dynamic". A dynamic phy body file must be created by using phygen. If it was auto-created by the editor/LE then it is a static phy body that will not respond to physics. Also since there have been multiple changes since 2.3 first came out in newton, the phy body might be of an older serialization that will not work with the current newton used in LE.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Got the Monstertruck working a while back. smile.png

As said, it needs a dynamic .phy file, and if I remember correct, the tires need a bit of renaming.

 

ZBrush 4R7 64-bit - 3DCoat 4.5 BETA 12 - Fl Studio 12 64Bit - LE 3.2 Indie version - Truespace 7 - Blender 2.71 - iClone 5.51 Pro - iClone 3DXChange 5.51 pipeline - Kontakt 5 - Bryce 7 - UU3D Pro - Substance Designer/Painter - Shadermap 3 - PaintShop Photo Pro X7 - Hexagon - Audacity - Gimp 2.8 - Vue 2015 - Reaktor 5 - Guitar Rig 5 - Bitmap2Material 3

Link to comment
Share on other sites

Hi, going back to this, do the wheel "have" to be seperate? Im a litle confused, the monster truck model has has wheels AND seperate wheels?

 

The Viperscout lua script refers to wheels that dont exist?

 

Ive made a "box" model car and apply the same script, the car moves and acts like a car, but no wheels turn or spin.

 

Whats the general "rules" to the vehicle, as there seems to be very little docs on the vehicles.

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

i put this in my "car.lua" :

and it is working

 

require("Scripts/class")
require("Scripts/loop")
require("Scripts/math/math")

local class=CreateClass(...)
function class:CreateObject(model)
 local object=self.super:CreateObject(model)

 function object:UpdateMatrix()
		 self:UpdateTires()
 end
 function object:UpdateTires()

		 local speed
		 for n=0,3 do
				 if self.tire[n]~=nil then
						 self.tire[n]:SetMatrix( self.vehicle:GetTireMatrix(n) )
						 if self.emitter[n]~=nil then
								 self.emitter[n]:SetMatrix(self.vehicle:GetTireMatrix(n))
								 self.emitter[n]:Pause()
								 if self.vehicle:TireIsAirborne(n)==0 then
										 speed = math.abs(self.model:GetVelocity(0).z)
										 speed = (speed - 4) / 20.0 --20
										 speed = Clamp( speed, 0, 1 ) * 0.5
										 if speed>0.2 then -->0
												 self.emitter[n]:Resume()
												 self.emitter[n]:SetColorf(1,1,1,speed)
										 end
								 end
						 end
				 end
		 end
 end

--local couronne
 local pivot
 local suspensionlength=0.2 --0.1 --0.2big
 local springconstant=280 --280 --70big
 local springdamper=500 --600 --220big

object.vehicle=CreateVehicle(object.model)

 object.tire={}
 object.emitter={}

pivot=object.model:FindChild("roue_avg")
	 if pivot~=nil then

			 tireradius=pivot.aabb.h/2.0
			 object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
			 object.tire[0]=LoadMesh("abstract::roue_avg.gmf",object.model)
			 pivot:Hide()

	 end

	 pivot=object.model:FindChild("roue_avd")
	 if pivot~=nil then
			 tireradius=pivot.aabb.h/2.0
			 object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
			 object.tire[1]=LoadMesh("abstract::roue_avd.gmf",object.model)
			 pivot:Hide()

	 end	
	 pivot=object.model:FindChild("roue_arg")
	 if pivot~=nil then
			 tireradius=pivot.aabb.h/2.0
			 object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
			 object.tire[2]=LoadMesh("abstract::roue_arg.gmf",object.model)
			 pivot:Hide()
	 end

	 pivot=object.model:FindChild("roue_ard")
	 if pivot~=nil then
			 tireradius=pivot.aabb.h/2.0
			 object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
			 object.tire[3]=LoadMesh("abstract::roue_ard.gmf",object.model)
			 pivot:Hide()
	 end	

 --object.emitter={}
 --object:UpdateTires()



--[[setWorld(fw.transparency.world)

				 for n=0,3 do
						 if object.tire[n]~=nil then --createemitter(50,2000,Vec3...
								 object.emitter[n]=CreateEmitter(1,100,Vec3(0,1,0),0,object.tire[n])
								 object.emitter[n]:SetPosition(Vec3(0,-object.tire[n].aabb.h/2.0,0))
								 object.emitter[n]:SetParent(model,1)
								 object.emitter[n]:SetRadius(0,2) --1.6
								 object.emitter[n]:SetWaver(0.1) --1.0
								 object.emitter[n]:Paint(LoadMaterial('abstract::dust.mat'))
								 object.emitter[n]:SetRotationSpeed(0.1)
								 object.emitter[n]:Pause()
						 end
				 end
SetWorld(fw.main.world) ]]--



--

 object.model.buoyant=0
 object.model:SetMass(2.6) --big2.20
object.model:SetFriction(0.9,0.9) --0.6,0.3
object.model:SetKey("Gravity",1)

 object.model:SetKey("collisiontype",COLLISION_PROP)
 ---object:UpdateTires()
end

 

in my folder i have the model gmf (with chassis as the parent of all pieces) and wheels (4 in my case)

 

 

and in mycarDriver.lua :

 

require("Scripts/constants/keycodes")
require("Scripts/linkedlist")
require("Scripts/filesystem")
require("Scripts/math/math")
require("Scripts/constants/engine_const")
FlushKeys()
HideMouse()
local camera = fw.main.camera
chassis=LoadModel("abstract::car_9.gmf")
carobject=objecttable[chassis]
car=carobject.vehicle
if car==nil then
    Notify("Vehicle object not found.",1)
    chassis:Free()
    return
end
chassis:SetPosition(TFormPoint(Vec3(0,1,4),fw.main.camera,nil))
chassis:SetRotationf(0,camera.rotation.y+180.0,0)
--Variables
local dx=0.0
local dy=0.0
local camerapitch=camera.rotation.x
local camerayaw=camera.rotation.y
local move=0.0
local strafe=0.0
local steering = 0.0
local torque = 0.0 --0
local steerlimit = 30.0
local steerrate = 2.0
local steerangle=0.0
MoveMouse(Round(GraphicsWidth()/2),Round(GraphicsHeight()/2))
while KeyHit(KEY_ESCAPE)==0 do 

    --Camera look
    --[[
    gx=Round(GraphicsWidth()/2)
    gy=Round(GraphicsHeight()/2)
    dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
    dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
    MoveMouse(gx,gy)
    camerapitch=camerapitch+dy
    camerayaw=camerayaw-dx
    camerapitch=math.min(camerapitch,90)
    camerapitch=math.max(camerapitch,-90)
    fw.main.camera:SetRotationf(camerapitch,camerayaw,0,1)
    ]]--
    local tirespeed=-(KeyDown(KEY_UP)-KeyDown(KEY_DOWN))*6.0 --2 vitesse origine
    car:AddTireTorque(tirespeed,0)
 car:AddTireTorque(tirespeed,1)
    car:AddTireTorque(tirespeed,2)
    car:AddTireTorque(tirespeed,3)

    steermode=0
    if KeyDown(KEY_RIGHT)==1 then steermode=steermode-1 end
    if KeyDown(KEY_LEFT)==1 then steermode=steermode+1 end

    if steermode==1 then
		    steerangle=steerangle+4.0*AppSpeed()
    elseif steermode==-1 then
		    steerangle=steerangle-4.0*AppSpeed()
    else
		    if steerangle>0 then
				    steerangle=steerangle-4.0*AppSpeed()
				    if steerangle<0.0 then steerangle=0.0 end
		    else
				    steerangle=steerangle+4.0*AppSpeed()
				    if steerangle>0.0 then steerangle=0.0 end
		    end
    end
    steerangle=Clamp(steerangle,-25,25)
    car:SetSteerAngle(steerangle,0)
    car:SetSteerAngle(steerangle,1)

 ---didier retourne vehicule
 if KeyDown(KEY_SPACE)==1 then
 ---chassis:SetRotationf(0,180.0,0) marche a peu pres
 chassis:SetRotation(Vec3(0,180,0)) -- marche mieux
 end--
 ---fin didier

    fw:Update()

 local campos=TFormPoint(Vec3(0,1,0),chassis,nil)

    fw.main.camera:SetPosition(campos)
    fw.main.camera:Move(Vec3(0,0,-8)) ---position camera derriere vh

    local t=TFormVector(Vec3(0,0,1),camera,chassis)
    a=-math.deg(math.atan2(t.x,t.z))+180.0

    fw.main.camera:SetRotation(Vec3(15,CurveAngle(180+chassis.rotation.y,fw.main.camera.rotation.y,10),0))
    --carobject.turret:SetRotationf(0,CurveAngle(a,carobject.turret.rotation.y,10.0/AppSpeed()),0)

    chassis:Hide()
    local pick = LinePick(campos,camera.position,0.5,COLLISION_PROP)
    chassis:Show()
    if pick~=nil then
		    camera:SetPosition(pick.position)
    end

    fw:Render()
    Flip(0)
end
chassis:Free()
chassis=nil
camera=nil
ShowMouse()

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

Link to comment
Share on other sites

Ok, well the code looks the same?

 

The model in your case, does the "chassis" have wheels? or is it just the chassis? Does the "chassis" have bones? If so are the bones only for locating where the pivots should be?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...