bue Posted June 17, 2015 Share Posted June 17, 2015 Hey, Im ashley (first post so better intraduce myself) and no im not a girl (I'm aware that Ashley is a girls name in America). Housekeeping aside, I've been experimenting with leadwerks (after only buying it 2 hours ago) and I'm finding it pretty triky to get this basic script to work. All I want is for the cube to move when I press the W key. So, this is my script (which is attached to a entity cube): player = Vec3(0,0,0) function Script:Start() -- housekeeping, init type function always needs to be there else I get cringie end function Script:WorldUpdate() --Update function if App.window:KeyDown(Key.W) then player:Move(1,0,0) end end any help and a little exsplnation would be awsome (I did know that the documentation was as bad as facebooks' but I still tryed to use it as much as possible along side the scripts that come with the engine, so I am trying >.< ) EDIT: I have player = Vec3(0,0,0) there because it makes more sence then just running Move(x,y,z) . I understand if someone facepalms becuase there's no reason for it to be there, but its just one of the many variations of code I have tryied. ALSO: sorry about spelling, For somereason firefox isn't picking up spell check in this wysiwyg Editor -.- SOLVED: Ok, so I managed to solve the issue. It turns out Script:WorldUpdate Isn't what I thought it was (basic Update function) So Insted, I have used Script:UpdatePhysics . From there I changed a few things and also learnt that I could reference the current entity with self.entity . So all together I have managed to pull this together: function Script:Start() -- basic init end function Script:UpdatePhysics() --Update function if window:KeyDown(Key.W) then self.entity:Move(1,0,0) end end Its incredably basic, and I feel pretty stupid but I was pretty stumped. Hopefully new programmers can use this as a basic example for movment. Quote Link to comment Share on other sites More sharing options...
Rick Posted June 17, 2015 Share Posted June 17, 2015 player in your script is just a vector (it's just a 3d point in space). It's not a cube. It has no visual to it. Quote Link to comment Share on other sites More sharing options...
bue Posted June 17, 2015 Author Share Posted June 17, 2015 player in your script is just a vector (it's just a 3d point in space). It's not a cube. It has no visual to it. Ahh I see, I thought it allowed me to dedicate a varible to the cube's current Vector Points. Now I know it just creates one, thanks ^.^ Also, how would I move the object? I've tryed self:Move() and just Move() but nothing seems to work. Quote Link to comment Share on other sites More sharing options...
Rick Posted June 17, 2015 Share Posted June 17, 2015 self.entity:Move() self.entity refers to whatever entity the script is attached to. It could be a model, camera, pivot, csg, light, etc. it's a special variable that Leadwerks creates and assigns for you. 1 Quote Link to comment Share on other sites More sharing options...
Olby Posted June 18, 2015 Share Posted June 18, 2015 It's all here: http://www.leadwerks.com/werkspace/page/tutorials/_/marble-game-r21#section4 Quote Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64) Link to comment Share on other sites More sharing options...
Recommended Posts
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.