Ok so I'm trying to learn some of the crazy ball game Josh posted. I know there will be some
material he is going to make for it in the future release of Leadwerks but I couldn't help but
to try and get started on my own. Wasn't the exact game Id like to make but I see some
mechanics I may be able to apply and learn here form prior tutorials. Ive got the ball and
camera working.
Here is the script some it I found here in a post.
Script.camera = "" --entity "Camera"
Script.soundfile1=""--path "Sound 1" "Wac file (*.wav):wav|Sound"
Script.soundfile2=""--path "Sound 2" "Wac file (*.wav):wav|Sound"
Script.soundfile3=""--path "Sound 3" "Wac file (*.wav):wav|Sound"
Script.soundfile4=""--path "Sound 4" "Wac file (*.wav):wav|Sound"
Script.threshhold=2--float "Threshhold"
Script.maxfrequency=300--minimum delay between sound plays
Script.range=20--float "Range"
--Global values
ImpactNoiseLastSoundTime=0-- This will be shared among all instances of this script and ensure we don't play too many sounds
function Script:UpdateWorld()
local window = Window:GetCurrent()
if window:KeyDown(Key.W) then self.entity:AddForce(0,0,10,true) end
if window:KeyDown(Key.S) then self.entity:AddForce(0,0,-10,true) end
if window:KeyDown(Key.A) then self.entity:AddForce(-10,0,0,true) end
if window:KeyDown(Key.D) then self.entity:AddForce(10,0,0,true) end
if window:KeyHit(Key.Space) then self.entity:AddForce(0,300,0,true) end
self.camera:SetPosition(self.entity:GetPosition(true) + Vec3(0,3,-6))
end
function Script:Start()
self.sound={}
for n=1,4 do
local filepath = self["soundfile"..tostring(n)]
if filepath~="" then
local noise = Sound:Load(filepath)
if noise~=nil then
table.insert(self.sound,noise)
--self.sound[#self.sound+1]=noise
end
end
end
end
function Script:Collision(entity, position, normal, speed)
if speed>self.threshhold then
if #self.sound>0 then
local collisiontype = entity:GetCollisionType()
if collisiontype==Collision.Prop or collisiontype==Collision.Scene then
local t = Time:GetCurrent()
if t-ImpactNoiseLastSoundTime>self.maxfrequency then
ImpactNoiseLastSoundTime=t
local n=math.random(#self.sound)
local noise = self.sound[n]
self.entity:EmitSound(noise,self.range)
end
end
end
end
end
Brings me to my first question.
Where is the default camera when you make a scene? When I create a camera its always camera 2
so I presume a default cam is always added and hidden from scene objects list?
First problem I'm dealing with is ball creation. Its never perfectly round. When rolling around the ball
it skips and makes sounds of course. In 3dmax u can scale an object uniform on xyz at the same time.
I cant seem to do that in Leadwerks? Ive tried grid snap and no grid snap always a ball that wobbles.
Well its a stone ball for now so its ok lol. Seriously why?
Second Ive kinda set up what Josh has initially in the game. 2 blades spinning opposite. When my ball
is in motion it reacts fine to the blades. Makes sound, get forced away etc. But.. When the ball is idle
the blades go right thru the ball like its not there instead of applying force/movement. I have played with
different prop types, mass and what not and have got some crazy results ranging from...
Ball falls thru platform, ball hits blade, blade moves and still spins till blade goes crazy off the map.
Blade just spins weird from the get go or falls itself.
I have the ball set - Rigid body, sphere get shape fit physics, mass 1.0, collision prop nothing checked marked after. As for the rotating blades ive tries all combo's I can conjure and have not found the right one.
I can't make a screen shot of the game running via print screen is there a Leadwerks feature for that?
After this point Im going to try and apply the death trigger script from Jorn's tutorial if the balls falls off.
If I get this far I know the next step will be wanting to learn the count meter to start, how to collect the
objects and count them in the score ect if anyone can provide any links/material for this dirrection
would be awesome, thanks a lot for any help.