Jump to content

i am new to LE and lua


RastiLechner
 Share

Recommended Posts

i have created a ball in editor i gave him physics mass and sphere collision.

in next ste i write for him script .

but the script don't work.

 

can somebody explain me whats the problem ?

 

script:

if KeyHit(Key.W) then Entity AddForce(0,0,100,true)

 

attached file is screenshot

 

thanks

 

p.s. sorry for my english

Link to comment
Share on other sites

no screenshot attached...

 

but just a simple example:

- Create the sphere and give it this for physics properties

post-14-0-56721600-1426724981_thumb.jpg

- Create a script and add the following code to it

Script.camera = "" --entity "Camera"

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
  self.camera:SetPosition(self.entity:GetPosition(true) + Vec3(0,1,-2))
end

-Attach the script to the sphere

-Drag the scene's camera into the sphere's script 'camera' textbox as shown in image above

  • Upvote 4

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

Thank you so much.. this was very helpfull for me

Script.camera = "" --entity "Camera"

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,500,0,true) end   
  self.camera:SetPosition(self.entity:GetPosition(true) + Vec3(0,2,-4))
end

ok thats cool but he jump in the air too

gives something like

 

if self.entity collision(world) then jump=true :end
if window:KeyHit(Key.Space) and jump=true then self.entity:AddForce(0,500,0,true) end  

 

thanks

Link to comment
Share on other sites

  • 2 weeks later...

Got this to work cool. One problem you can keep jumping the ball even in the air.

I presume this line of code prevents that.

if self.entity collision(world) then jump=true :end

 

 

Of course its not right Ive fiddled around how to properly add it in?

 

Script.camera = "" --entity "Camera"

 

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,500,0,true) end

self.camera:SetPosition(self.entity:GetPosition(true) + Vec3(0,1,-5))

end

 

Thanks.

CB

Link to comment
Share on other sites

Can anyone help with the above question? Also I have a rotating block to navigate my ball around. If my ball

is already rolling everything reacts right. I hit the rotating block and it forces me to move etc but...

If my ball is standing still/idle the rotating box goes right thru my ball as if its not there. Ive messed with settings

and mass and what not and can't find a working combo. Lastly do I really need to make a sphere in 3dsmax and

import into Leadwerks because I can NOT get a perfectly round ball no matter what I try in Leadwerks am I missing

something so simple? How do you scale object on all xyz at the same time? In 3dmax you grab where the x.y.z meet.

I I hope someone can comment so I can progress soon.

 

Edit I have the same ball settings as illustrated above. Must be the box setting. There is no collision if the ball

is NOT in motion, odd. Off to tinker some more. Edit Tried all settings/combinations arrrrrrr!

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