Charrua Posted June 19, 2014 Share Posted June 19, 2014 not all is work! Here the code that does the magic: Create a sphere on start function Script:Start() --as this script is attached to the camera, here is a good place to --set a global camera variable and so, it can be used in any other script of this project. camera=self.entity --Create a sphere to indicate where the pick hits self.picksphere = Model:Sphere() self.picksphere:SetColor(1.0,0.0,0.0) self.picksphere:SetPickMode(0) self.picksphere:SetScale(pickradius*2.0) self.picksphere:Hide() System:Print("fly.lua start") end on the update world function: if appWindow:MouseHit(1) then local pickinfo = PickInfo() local p = appWindow:GetMousePosition() --do a camera pick --place a new instance of the picksphere ent at the picked position --place a hinge joint to keep the sphere and the picked object together if (camera:Pick(p.x,p.y,pickinfo,pickradius,true)) then local newEnt = self.picksphere:Instance() newEnt:SetPhysicsMode(Entity.RigidBodyPhysics) newEnt:SetMass(10) local shape = Shape:Sphere() newEnt:SetShape(shape) shape:Release() newEnt:SetPosition(pickinfo.position) local hingeVar = Joint:Slider(pickinfo.position.x, pickinfo.position.y, pickinfo.position.z, 0, 0, 0, pickinfo.entity, newEnt) hingeVar:SetLimits(0,0) hingeVar:EnableLimits() newEnt:Show() end end a note about: appWindow on app.lua, i declare this global variable and pass the window created there, so i can use it on any other script here the modification of app.lua: appWindow=nil --global variable, so fly.lua can reach and use the window created on start function App:Start() --Initialize Steamworks (optional) --Steamworks:Initialize() --Set the application title self.title="MyGame" --Create a window self.window=Window:Create(self.title) --self.window:HideMouse() --do not hide the mouse pointer appWindow=self.window --set the global variable appWindow with the window just created --rest of the script/function as default 5 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
gamecreator Posted June 19, 2014 Share Posted June 19, 2014 Nice. It's definitely fun to play with the physics. That's most of the reason why people like making rolling ball games. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted June 20, 2014 Share Posted June 20, 2014 @Charrua : Good dig on physics. You could make physic on big plants using Slider perhaps ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Charrua Posted June 22, 2014 Author Share Posted June 22, 2014 sliders will came late... and balls also i'm still playing with hinges. 4 or 3 wheels: tricycle or car.. very elemental, with no control (until) a couple of captures, on the editor, and running the code. the video is uploading... 4 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Haydenmango Posted June 23, 2014 Share Posted June 23, 2014 That is awesome! Physics is the one area of this engine that I haven't started exploring yet. I like what you've done here I can see that there are lots of interesting combinations you can create. Very inspiring! 1 Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Charrua Posted June 23, 2014 Author Share Posted June 23, 2014 thank's if i have time, my intention is to create some prefabs/scripts to play with. is a way of learning and have fun. Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
shadmar Posted June 24, 2014 Share Posted June 24, 2014 262000 trees at 15 fps. Using grid for the close ones and geometry shader for the 261500 billboards. Edit: not sure how this got into this thread.. 7 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Charrua Posted June 30, 2014 Author Share Posted June 30, 2014 @shadmar: nice unrelated shoot!, at least it gives some beauty to this thread... ok, now i'm controlling steer and speed not too much stable, but working 2 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
YouGroove Posted July 1, 2014 Share Posted July 1, 2014 not too much stable, but working In the video seems really stable. You would just need some physic Spring system in LE3 and it would be enought to make any car system. 1 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Shadoh Posted July 1, 2014 Share Posted July 1, 2014 I made a vehicle system once, it was super glitchy I programmed the springs myself using a hing joint and applying force using scripts to keep it at a certain angle I'm sure there's got to be a better way to do it though. Adjusting how much force was applied would adjust the spring stiffness, increasing force the more angle it was away from it's target angle. Quote Link to comment Share on other sites More sharing options...
Charrua Posted July 1, 2014 Author Share Posted July 1, 2014 i'm using hinges only. to get wheel rotation, simply read the current joint angle and set it to some value ahead, having motor enabled speed is controlled by MotorSpeed wheels are cylinders ... made by segments and so the whell gets jumping constantly and so, the vehicle goes slower that it should... if you tell the camera to follow the vehicle, then you will see how unstable it is... i'm not applying forces/torque, just MotorSpeed, Limits, Angle also, to much or to less mass on the individual parts of the vehicle make it behave differently, bad/worse i'm doing some code-clean-up, then i will post the scripts i'm using. Not sure if it is the correct way of doing things, but problably some one can point me in the right direction... thank's for the comments Quote Paren el mundo!, me quiero bajar. 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.