Jump to content

Marcousik

Members
  • Posts

    678
  • Joined

  • Last visited

Blog Entries posted by Marcousik

  1. Marcousik

    Offroad car simulation
    This diary counts so much steps to reach a good experience of car driving with Leadwerks 4.6, that it just felt so often like unreachable.
     
    So as we know the car is built with 8 joints, 4 hinge joints for the tires  + 4 slider joints for the dampers
    I just thought last week about implementing a new little trick like using a spring joint more to connect the visible car to the invisible body of the car.
    Set the mass to about 300 (usually to heavy for joints) and set the Gravity to false just for this car part...
    And that's what I obtain:
     
    It allows speed until 150-200 km/h, correct behavior by drift, springs, collisions, no trembling.
    So I'm fine with this,
    Have fun, thx for watching
     
     
  2. Marcousik

    Offroad car simulation
    Considering this blog as a diary of progress about car simulation with Leadwerks,
    I had the dream to simulate those desert crawlers able to climb on sharperned hills with a lot of impuls,
    Swinging on the roads as they're light, allowing the player to discover rapidly a large part of the map.
    Technically all the features (directions, dampers, smoothing, acceleration) get simplified but adjusted to be in a good balance.
    The car may be overpowered but it's fun!
     
  3. Marcousik

    Offroad car simulation
    > This is defintely the best result I obtained with Leadwerks physics to build a car; I think this car is good enough so that it could be used in a game.
    > The car reacts depending on terrain, feeling different if climbing or driving down. The car allows speed driving until 140-160 kmh
    > The dampers became an upgrade that give me the possibility to construct car over 200 kg. That means simply that the cars drive now with much more stability and give for the player heavier feeling.
    > It approachs the feeling you get in games klike GTA 4.. Even if the car doesn't really get out of control like sometime it happens ingame when cars are drifting.
    > Car balancing and transmission could get more fine tuning, but this should be no problem.
    Here is the demo:
     
  4. Marcousik

    Offroad car simulation
    This  an entry for a new completed feature:
    Wheels can leave a trace on the ground using decals.
    Here is a bit code on how to make that work.
    Here is how it returns ingame:
     
    Edit 19.01.2022
    First visual mud effect: 

    TEMP 2022-01-19 12-53-14.mp4  
     
    Enjoy!
  5. Marcousik

    Offroad car simulation
    Hello
    Debuting 2022 with a very first try of a level design for my offroad game project I try to construct with Leadwerks 4.6
     
     
    The map needs a lot more improvements.
    There are a few bugs (like swimming) and some collisions problems, but this how it could look like, with the challenge for the player to find his way through the world - like a puzzle driving game - without getting stucked (like me in this showcase) or have your car destroyed. So I will add an health system, but that should be easy to make.
    I want to add mud and water effects (visual and physics)
    The story will be something about to re-construct an abandonned world.
    Have fun and thx for watching.
    Thx for modelling:
    "GAZ-66 Offroad Truck" (https://skfb.ly/6x8Ru) by Yo.Ri is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
     
  6. Marcousik
    Still researching a good car simulation script with LE 4.6, so what's new:
    I changed some important parameters of my car script to make the car more nervous, better responsive to the world, rapid and giving more feelings and more controls by driving it.
    Maybe it is not 100% what man can expect but it is now more  fun to drive and that's important.
    The car now calculates and integrates both the forces coming from the world and from the player commands, 
    That means it checks the slope movement of the ground, check its own rotation and adapt its own position depending on the results.
    The slider joints that simulates the dampers are now using SetSpring() combined with Motorspeed(),
    The frictions of the tires have a responssive adaptation to the controls,
    The dampers are now much more heavier than  I was used to use,
    Kynetic energie and inertia forces are integrated to the controls so the car has its own behavior too.
    I believe I can get it more smoother than actually it is, but it is a completly new way that awaits to be tested.
     
     
  7. Marcousik
    Example:

     
    I could strangely find nothing about terrain generation from script except for LE5... 
    So here is an example that will run with LE4.6 on how you can generate 2 little  hills on a terrain and paint it from script. Can be usefull for games with random generated landscape.
    The script I modified is from here: https://www.leadwerks.com/community/topic/15715-minimap-generator/?do=findComment&comment=104697
    So first install the minimap shader to run this:
     
     
    You can only handle 4 layers from the script: 0,1,2,3. More will have no effect.
     

     
    > Add this to create vegetation:
     
  8. Marcousik
    > Work in progress
    > The road tracer tool is  for now without bug; I added debug messages that prevent a bugged road to be generated - so it asks now to modify some values instead of generating the bugged road.
    > Water waves are smoother.
    > New feature: Driving in mud.
    > I'm thinking about adding a speed or friction penality if not driving on roads.
    > This little demo was recording on map 2048*2048
     
  9. Marcousik
    January 2021, work progression showcase random generated world vegetation, FPS=30
     
     
     
     
    [I] -  THE TERRAIN; VEGETATION AND WATER:
     
    The map is 4096*4096
    The landscape is randomly cast: Painting & vegetation.
    At the end of the video, is a demo of the waves shader I could write using the leaves.shader on the water.shader.
    The shader is in the workshop for free to use. It is far not perfect but it adds a good animation for ocean water.
    https://steamcommunity.com/sharedfiles/filedetails/?id=2182253514
     
    [II] - THE CARS PHYSICS:
    In the game the player will have the possibility to drive different cars: Motos, Jeep, rapid cars,  heavy PIckup, trucks.
    All vehicles will have upgrades to buy or loot.
    That means not all vehicles will be able to cross a hill, depending on how heavy or how upgraded th car will be.
    So first challenge will be to find a way in the world.
    Here is a little showcase of a climb simulation for an heavy jeep (the model should rather be a heavy truck but that is not done yet), that fails to climb an abrupt mountain:
    You can see the speed of the vehicle depends on how straight the slope is be taken.
     
    thx for watching - feel free to comment, critic or advice.
     
     
     
  10. Marcousik
    I really wanted to use the spline tool to make roads because it is a powerful tool but it has a big inconvenient: It builds the spline as you want but then moves the terrain to pass it to the spline - this sounds first ok but using this especially on big maps, you end up with a terrain that shows artificial big too sharpened contours and hollowed areas where the road is going through.
    To avoid this problem, you have to place a lot of spline pivots and nodes very carefully on the map, following the actual terrain movement. This takes hours and the result is disapointing if you forget one hill, it will shows this ugly sharpened cutted unnatural shapes.
    That 's why I want to build a tool that operates on the terrain but with the feature to pass the roads to the terrain and not the opposite.
    It should operates like a bulldozer does: Moving on the hills (and not cutting them!) the bulldozer builds a large passage practicable with a car.
    Here in this little demo, you simply need to throw 2 pivots on the map - no matter the height where they are placed - and the script calculates the rest:

    TEMP 2020-08-09 00-29-31.mp4 Script function for a straight road looks like that
     
     
    2) Building curves:

    TEMP 2020-08-15 23-14-38.mp4 Code for curve looks like this:

     
    Showcase: Just tell the editor where the roads has to pass through to get this: (placing a few pivots)

    TEMP 2020-08-18 23-51-21.mp4  
    3) roads junctions are done ?
    Always keeping the simpliest way:
    With 3 pivots in the map, the script automaticly  generates the first road segment with 1 curve. With 3 others pivots in the map, it builds the second road segment with 1 curve too. Then only add the second road segment as junction entity in the first road segment script property and the segments will be correctly calculated and attached together:
    4)  Texturing the roads:
    The textures will be drawn between the little sphere, creating surfaces and vertex in an appropriate way.
    The surfaces have to be joined ttogether from one road part to the next. Then only need to be shape.
    Well the first road is done, throwing 2 * 3 pivots on the map, where you want the road to go through, then attach the 2 road segments together with drag and drop property entity.
    More is not necessery to do...and the script calculates the rest, here a little showcase of the road:

    TEMP 2020-08-27 11-46-04.mp4
  11. Marcousik
    Hellö
    Here are a few thoughts about finding the best way to create  a dense forest, with different models, quickly, dense and allowing good performances by walking and driving.
     
    I first try with the vegetation tool. https://www.leadwerks.com/community/profile/15151-marcousik/?status=10763&type=status           I got good results but not by driving and I find that the collision checked causes the lost of 40 FPS (from 60 by to 20) making the game unplayable.
              Sure this depends on the view range and the density.
              I could get such a good beautiful looking map, allowing fast driving, but NOT allowing collision enabled, so that was sadly a no go.
     
    I tried on a another map to write a little script allowing a random generated forest with 2 colliding trees models and making the not colliding vegetation with the vegetation tool.           I obtained good results, possibly ok to be used in a game or a part of.
              The positive thing is that you can rotate the generated trees in x and z axes too, or changing the basis height easily, making a more realistic forest.
              There are performances limitations with this method too for sure: not the collision (setting collision to none didn't actually change very much regarding FPS, strangely?) but the density and the                      global range you wan't to be covered with trees. So it stays totally impossible to cover all the map (1024) with trees if you wan't a dense forest, like in the video here, with this method. The                            vegetation  tool should be better for covering all the map, if requested.
     
              But I found that I could create little dense forest allowing faster driving through. That's cool.
              I expected too much from setting the view range to medium or far. I thought that not rendering the trees that are far away would be equal to a none performance cost. Sadly it is not like this.
             So if the generated forest is big and very dense, even if invisible because far away from the player (by setting medium view range), the FPS are sinking drastically. Strange ? What/Where are the                 performances gone for?
             Another problem with this method is that the nav mesh will not be able to assimilate the trees as they are build in the start function. Except you generate the nav mesh after this from the script...
             Car lights are not supported, FPS sinking immediately under 20. Perhaps can here something be done with shadow disabling? Not tested. 
             Light are ok if the forest is not so dense. (but especially when the forest is dark and dense are the car lights really useful!)
     
    Conclusion, this tool script is ok for making little forests allowing fast movement and looking more diverse and realistic in my opinion... It is possible to add an if statement on the Terrain:GetSlope() and/or GetElevation() to choose if the trees should be summoned or not depending on the Height and Slope of the map, same options as in the vegetaion tool. The GetTerrain() function runs with the spline tool - but you can find the terrain using a selection with if GetClassName()=="terrain" on all entities on the map until it find it. You can summon all what you want with this, randomly, add more options... Rocks, mushrooms, flowers whatever. Using Terrain:GetElevation() is a much more powerful as with Pick() Script and video showcase following + beautiful screenshots done ingame with this tool:
     
     
     
     
     
     
     
  12. Marcousik
    I focused my imagination on game art, trying to create a beautiful world where players may want to explore and drive.
    The first quest could be: Find a way out of the forest.
    Here is a little showcase of what I made:
     
    Edit: 27.04.2020
    The goal was to get the better I could out of a 4096x4096 map, after months work trying all possibilities I obtained a good decor and great area for an offroad game.
    Performances are a bit slow but so much models was added - I never thought I could obtain this until I found that the shapes and the collisions are slowing the map extremly and did ruin the positive effect of using SetViewRange(Far) or (Medium) on the models to get better performances.
    So I developped a method that removes the shape and add them to the models that are only near the player, in a dynamic way. And now almost an infinity of models can be added ? And all the trees or the stone can possibly get a script to be cut down or harvested or whatever. Each model stays unique.
    So this density could be possible:
     
     
     
  13. Marcousik
    Using joints Hinge()
    Joints are funny and powerful to build machines. They allow to use mass (gravity), different masses on different part of the machine depends on what you need, frictions, and limits.
    By this machine, the only enabled motor is the first big oval cylinder, which is turning. The rest is articulated with disabled hinge joints.
     
     
  14. Marcousik
    I'm still spending hours of tests, changing and seeking properties to obtain the best balanced car driving experience possible.
    It's something between the mass used, the joints values, and the smoothing force. 
    This until now the best I get with a car, which is even performing a salto jump at 2.30 and other somersault crashing at 3.15
    The FPS are nice, I'm happy with this.
     
  15. Marcousik
    This little game is here free to play:
    https://1drv.ms/u/s!AiVBgjDAyIXLs1khcglU6UKFbI_4?e=4oK8Sj
     
    1] First step:
    Adapting the Spline tool to build what we need: 
    I combined some of the possibilities that offers the Spline Tool (great thing) to obtain all this in one:
    - Cars align and follow the roads (rotation)
    - While using Physics, and so collisions
    - While using reverse travel (cars go back on the road)
     
     
    2] next step: 
    - We need speed cars in this game, beautiful , well smoothed, and challenging that can drive a few rounds on a loop racing road, here it is:
     
    I'm just thinking there is no way to overtake this car ! So we have here a nice challenging game.
    Next step will be build a playable race car, maybe able to overtake this.
     
     
    3] Playable speed car
    this video shows a little playable demo challenging 3 cars, here  I only get the second place:
     
     
    Last step should be adding Speed infos, Time needed, best time, the place..
    4) Here I managed a player interface to get informations like the speed and the place at which you are actually driving.
    A little bit car optimization, and here is a little funny challenging game. 
    Next step should be adding options like choose your car model and colors, sounds, music, how much players...
     
  16. Marcousik
    Workshop car "Turbo car for Le 4.6 free" - Uploaded in the Workshop
    Better optimization for the workshop car released. And possibility to custom the car, feel the difference of the configuration when driving.
    For Le 4.6. with world:update(4) added to the main script 
    Here is a demo video about the new optimization:
     
    Here are the properties that allow to change the car:

     
    - The Drive Factor makes the car drive feeling more or less heavy: With a value of 5 it will feel heavy, and it becomes much lighter using a value of 25 for example
    - The car mass can be changed: Range about 50-200.
    - The Tires mass can be changed: Range about 5-20.
    - The motor speed will change the car too:Range about 5000 - 50000.
    - The brake force has an impact on the time the car will need to be stopped
    - The springs force value determine how the car bounces on the tires: Range about 500-10000, depending on other values.
    Enjoy trying it !
     
     
     
     
     
  17. Marcousik
    Finishing this today, I'm happy to publish this: https://steamcommunity.com/sharedfiles/filedetails/?id=1662222417
    The car is funny to drive, the prefabs is ready-to-use but feel free to change the script variables to test it.
    Drop the prefabs in the map, it uses the classical FPSPlayer from Leadwerks.
    The car is based on joints: 4 wheels, 4 damper and 2 Hinges for the directions.
    The script incorporates smoothing damping modifications to get the car stable; modifications on the velocity.
    There is a funny speed boost system added.
    Here is a little video test:
     
    Have fun
  18. Marcousik
    That's what I obtained for driving experience with 4.6.
    For me it's ok, just the distance of the wheels to the cars are growing too much while getting speed.
    Sounds have to get upgraded too
     
    I add a video that show car driving possibilities in the down-scaled world I want to create with an own scaled character controller. The idea is to obtain with this a bigger world lol
    So everything is under scaled, the car too.
    It's not GTA 6 but it's very ok for what I expect because I like when the car you drive is shaking on the road, as too much polished is not realistic enough, as you could not feel the ruggedness of the world you are playing in . I think the cars in gta 5 are definitvly too polished as you cannot reverse them for example, making the game a way too sanitized.

     
     
     
     
    Progress of this update 02/2019:
     
     
     
     
     
     
     
     
  19. Marcousik
    Working out of this subject:
     
    I tested a script for a simple "GoToPoint()" function for a customizable character controller for NPC. This may not be so good as the implemented LE character controller with classic navigation system but it could be promising to use it in open world (so not in much corridored dungeon game!) where the the NPC should crawl or swim or whatever do things as for example underscaled world (thats what I am actually interested in ?)
    The NPCs are using an "intelligent" World:Pick() system to find their way.
    The positive things in this are:
    - No need nav mesh to be build / free moving system
    - dynamic way searching so removing a block may let the NPCs go through
    - swim, crawl, crouch with triggers should be no problem
    - NPC are not only following a prepared way but they can be thrown as Patrol, choosing randomize positions to go, inside an area.
    - Scale as you want
    - The system let the NPC make a little analyse out of the Pick Infos so the way should be a human-logical way
     
    The negative point are:
    - The path will not be planned so far as allows the actually Navigation Leadwerks System so it is for sure not impossible that a NPC doesn't find the best way to go.
    This system does definiv not allow a NPC to "know" his way through the entire map. All NPCs are trying to find the best way from the position where they stay at the mooment, so never sure if/what they will find (no return of true/false that let you know the NPC found a way...)
    (even if this could be solved with "forcing" through a pivot where the way may be too complicated to find...)
    - The NPCs doen't move "round" but straight from point to point.
    - For sure more...? ?
    Here is a little demo:

    Testing 13.08.2018 20_00_48.mp4  
     
  20. Marcousik
    I'm just happy to get this work  here is a demo:
    This is actually better than driving in 4.3 because cars are now  able to jump or crash without experimenting crazy rotations or whatever  ?
     
     
    Here is the script to make this:
     
    > Here the values I used:
     

     
     
    > And here what changed: Is written in dark:
    -------------------------------------
    function Script:Start()
    -- [...........]
    -- Construit les amortisseurs: / suspensions
    local n
    local pos
        for n=0,3 do
            pos=self.entity:GetPosition(true)
            self.Axes[n]:SetMass(self.TireMass)
            self.Amortisseurs[n]=Joint:Slider(pos.x, pos.y, pos.z, 0,1,0, self.Axes[n], self.entity)
            self.Amortisseurs[n]:EnableLimits()
            self.Amortisseurs[n]:SetLimits(-0.25/2,0.25/2)
            self.Amortisseurs[n]:SetTargetAngle(-self.Amort)    --at the middle if 0
            self.Amortisseurs[n]:SetMotorSpeed(10000)    ------------- vitesse de la pompe/ suspensions speed
            self.Amortisseurs[n]:SetStrength(self.Force)    --defatul is 1000
            self.Amortisseurs[n]:EnableMotor()    

        end
    -- [...........]     
     
    -----  I removed the backward suspensions with 2* forces because this only depends on the positions of the suspensions on the chassis.
    ----- Making them symmetrical is ok to solve this.
     
    ----------------------------------------
    function Script:UpdatePhysics()

    if self.MyCar==1 and InCar>0 then
        
    -- Traite la direction:    
    local turning=0
        local direction=self.Volants[0]:GetAngle()
        if window:KeyDown(Key.Left) then
            direction=direction-5 turning=-1
        elseif window:KeyDown(Key.Right) then
            direction=direction+5 turning=1
        elseif window:KeyDown(Key.Left)==false and window:KeyDown(Key.Right)== false then 
            if Math:Round(direction)>0 then direction=direction-5
            elseif Math:Round(direction)<0 then direction=direction+5
            end
        end
        self.Volants[0]:SetAngle(direction)
        self.Volants[1]:SetAngle(direction)
    -- Traite l'acceleration:
    local Gas=0
            if window:KeyDown(Key.Up) then
                Gas=1
                self.currspeed = self.currspeed + 10
                if self.currspeed>self.SpeedMax then
                    self.currspeed=self.SpeedMax
                end
            
            elseif window:KeyDown(Key.Down) then
                Gas=-1
                self.currspeed = self.currspeed - 10
                if self.currspeed<-self.SpeedMax then
                    self.currspeed=-self.SpeedMax
                end
            end
            if Gas==0 then  self.currspeed=0
                for n=0,3 do
                self.Rouages[n]:DisableMotor()
                end
            else
                for n=0,3 do
                if self.Rouages[n]:MotorEnabled()==false then self.Rouages[n]:EnableMotor() end
                self.Rouages[n]:SetTargetAngle(self.Rouages[n]:GetAngle()+1000)
                self.Rouages[n]:SetMotorSpeed(self.currspeed)
                self.Tires[n]:SetOmega(self.Tires[n]:GetOmega()*Vec3(5,5,5))   ---------  make the car go faster
                end
            end
    --Smoothing:
    if turning==0 then
        self.entity:SetOmega(self.entity:GetOmega()*Vec3(-1,-1,-1))
    else self.entity:SetOmega(0,turning*Gas,0) end
        self.Axes[0]:SetOmega(self.Axes[0]:GetOmega()*Vec3(-1,-1,-1))
        self.Axes[1]:SetOmega(self.Axes[1]:GetOmega()*Vec3(-1,-1,-1))
        self.Axes[2]:SetOmega(self.Axes[2]:GetOmega()*Vec3(-1,-1,-1))
        self.Axes[3]:SetOmega(self.Axes[3]:GetOmega()*Vec3(-1,-1,-1))
        self.Axes[0]:SetVelocity(self.Axes[0]:GetVelocity()*Vec3(1,0.5,1))
        self.Axes[1]:SetVelocity(self.Axes[1]:GetVelocity()*Vec3(1,0.5,1))
        self.Axes[2]:SetVelocity(self.Axes[2]:GetVelocity()*Vec3(1,0.5,1))
        self.Axes[3]:SetVelocity(self.Axes[3]:GetVelocity()*Vec3(1,0.5,1))

    -- fake wheels update:
        
            self.Wheels[0]:SetMatrix(self.Tires[0]:GetMatrix())
            self.Wheels[1]:SetMatrix(self.Tires[1]:GetMatrix())
            self.Wheels[2]:SetMatrix(self.Tires[2]:GetMatrix())
            self.Wheels[3]:SetMatrix(self.Tires[3]:GetMatrix())
            self.Wheels[0]:SetPosition(self.PosWheels[0]+Vec3(0,self.Amortisseurs[0]:GetAngle()/6,0))
            self.Wheels[1]:SetPosition(self.PosWheels[1]+Vec3(0,self.Amortisseurs[1]:GetAngle()/6,0))
            self.Wheels[2]:SetPosition(self.PosWheels[2]+Vec3(0,self.Amortisseurs[2]:GetAngle()/6,0))
            self.Wheels[3]:SetPosition(self.PosWheels[3]+Vec3(0,self.Amortisseurs[3]:GetAngle()/6,0))
    end
     
×
×
  • Create New...