Anything to do with physics. Rigid Bodies, Kinematic controllers, vehicles etc.

Vehicle setup

Vehicle setup

Postby planetX » 09 Dec 2016, 17:27

Hi,

I've decided to open this post as I'm pretty sure I will have more than one question about setting up all the vehicles I want in the scene, so this is going to be long I guess... I've started with the player car, which I already have it running in the scene. The car is a Physx Vehicle which gets all the settings from a .car file. I just want to add all the sounds, particles and stuff the Racing Demo car has. :o

Q) I've started by copying the script from the demo and saved as an external script inside my projects folder. When I try to apply it, it doesn't work. It only works if I add it as microscript. I've tried to change the VehID variable to 5, which is the ID of the entity, but nothing happens... what should I do to use external scripts in a Physx Vehicle?

Q) There are some settings in the script which are the same as in the .car file. Do they overwrite the original seetings?

Q) I've noticed that there's no absolute nor relative paths to the files linked in the script... does that mean that all the resources must have a different name? Does the script search for resources outside the Assets Library as well?

Thanks in advance! ;)

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby SolarPortal » 09 Dec 2016, 17:38

wow, i knew this was coming around one day with vehicles lol :P
I will try my best to explain :)

Q) I've started by copying the script from the demo and saved as an external script inside my projects folder. When I try to apply it, it doesn't work. It only works if I add it as microscript. I've tried to change the VehID variable to 5, which is the ID of the entity, but nothing happens... what should I do to use external scripts in a Physx Vehicle?

We have heard a few cases where external scripts are not working at times and will have to try and reproduce this :)

But before we do, did you by any chance add the external script to your resources?
To do this, please open the Asset Manager > Then locate where you file is in the explorer. Then you have 2 options,
- When clicking on the folder containing the script file, it may ask if you want to add some files that are new there to the resources. Press yes.
- Or, on the explorer list, try right clicking and going to Resource Management > Add folder to resources.

Then try running your external script again. Hopefully this will help :)

Q) There are some settings in the script which are the same as in the .car file. Do they overwrite the original seetings?

I believe so, but they also allow you to adjust the handling of the cars on the fly. For instance, if you go fast and turn, then you can adjust the friction settings of wheels to slide. Then apply forces and you can make cars drift etc..
Its one of my personal goals to get a pacejka model working with vehicles and get a simulation style car working... lol :P

Q) I've noticed that there's no absolute nor relative paths to the files linked in the script... does that mean that all the resources must have a different name? Does the script search for resources outside the Assets Library as well?

Yes, in skyline all resources must have unique names. It has caused issues over the years which is why the prepare folder option converts all filenames into names that dont exist.
Our resource system works on a per file basis and stores the folder path where it was found, which means if assets are moved around, the resources need removed and added again in the system> This can all be done from the asset manager.

However, what this allows is a full asset library that can be shared between projects and stops the old crappy design of other engines where assets have to be duplicated to be used in another project. We never liked this and is why we designed it the way it is today.

When the game is exported, we run a resource collection which scans all the scene files, script files, meshes and material files to locate all the resources used and copy them into the end game directory.
So, to answer the question simply, Skyline itself can find files which means all you have to pass is the name of a file and keep files unique, the engine takes care of the rest :D

Yes, Skyline can store reference resources to any hard drive location. However, if you delete the resource files or recreate the full list, then you have to add the root folder again and it will parse down loading all resources :)

Edit: Most systems in skyline, if it creates a file.. it usually adds it to the resources. But there are soe features which do not and you may have been caught in one of these where you are required to manually add it lol :P
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 09 Dec 2016, 18:14

Hi, thanks for the quick reply and lots of info, slowly I'm getting the basics... :D

SolarPortal wrote:But before we do, did you by any chance add the external script to your resources?


I think I've added all the new files to the resources from the beginning, but repeated the process and still not working. I've also tried to reproduce it in the racing demo, with the same results.

Can survive with microscripts in the meanwhile, just wanted to check that I'm not doing anything wrong... :lol:

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby SolarPortal » 09 Dec 2016, 19:36

Hi, thanks for the quick reply and lots of info, slowly I'm getting the basics..

Thats good that you are getting the hang of it :)

If you dont mind me asking, but which vehicle file exactly was it you copied from? as i would love to replicate this myself and hopefully find and fix any remaining issues with the external script.
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 09 Dec 2016, 20:01

SolarPortal wrote:If you dont mind me asking, but which vehicle file exactly was it you copied from? as i would love to replicate this myself and hopefully find and fix any remaining issues with the external script.


I copied the microscript from the Porsche 911, the player car from your racing demo, and saved as external script in my project folder.

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby SolarPortal » 09 Dec 2016, 21:43

Thanks :D

Edit 1) For some reason, i too had the the same external script issue from that car.. will investigate further :)

Edit 2): Upon further investigation, we found that the external script is working as intended however there is an ordering issue at play.

Skyline boots like this:

SceneScript onInit()
External Scripts onInit() -- Allows pre - action execution of information
Action - onInit.

Now the reason the script didnt work was because the isPlayer in lua was being set to 0 on the external script, because the vehicle action had not initialised yet. The microscript worked because its an action and it was also placed after the vehicle action. So the vehicle initialised and then the microscript onInit was called.
You would get the same problem as external scripts with microscripts if they were before the "PhysX Vehicle".

Solution:
Place what is inside the onInit function into the postInit()
PostInit() is called across everything after the onInit of everything has been called to ensure when something is called or setup, the information is there unlike onInit which is called on things first go.

Overwrite your vehicle external script's onInit() with this code and it should work as normal.
Code: Select all
function onInit(objID)
   obj = objID;
end

function postInit()
   sky.setVar("Vehicle_ParticleType", "asphalt");

   vehID = vehicle.getVehicleID(obj, "");

   createSoundData();
   createParticleData(sky.getVar("Vehicle_ParticleType"));
   
   isPlayer = vehicle.isPlayer(vehID);
   sky.lprint("LUA: vehID!"..vehID);
   sky.lprint("LUA: isPlayer!"..isPlayer);
   if(isPlayer == 1)then
      sound.play3DSound( lowSound_ID , 0, 0, 0 );
      sound.play3DSound( highSound_ID , 0, 0, 0 );
      sound.play3DSound( skidSound_ID, 0, 0, 0);
   end
   --sky.lprint("LUA: VEHICLE Script Active!");
end


Hope this helps :D

Edit: When editing the .car file, you may find this document helpful: http://www.chi-ad.com/DokuWiki/doku.php/english_manual:res_vehiclesetup
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 09 Dec 2016, 23:01

Oh yeah, it works! :D

Thank you very much for the support and the extended explanation, I really appreciate.

SolarPortal wrote:Edit: When editing the .car file, you may find this document helpful: http://www.chi-ad.com/DokuWiki/doku.php/english_manual:res_vehiclesetup


Got it in my bookmarks since a week ago... ;) Still need to go a lil bit deeper, but more or less I get it.

This is what I got today:



I need to change the color of the ribbons via script... is that possible? There are two values in the script (FadeColour and InitialColour) that I've tried to change, but couldn't get rid of that black. Any clue?

Code: Select all
   ribbon.setFadeColour(ribbonID, 0.0, 0.0, 0.0, 0.0);
   ribbon.setInitialColour(ribbonID, 1.0, 1.0, 1.0, 0.0);


Thanks!

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby StarFire » 09 Dec 2016, 23:19

Sweet, loving what you are doing. Great to see some thing different, especially with the cars :D
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1419
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: Vehicle setup

Postby SolarPortal » 09 Dec 2016, 23:35

haha :P Superb! You pulled it off and it looks like a great vehicle. :) :) Makes me very happy to see lol :P
Have you tried it with an xbox controller or something? as that script was programmed with joypad also.

As for the ribbons, are you using your own texture? There was an issue on the ribbon trail back then, that the texture had to be 1D.
This means you can have a 128 texture but it can only be 1px height. Check out the ribbon texture default to see what i mean :) It might be in the data folder.

I haven't played with those settings in some time due to programming Gen2, but i can open Gen1 tomorrow and have a look to see if i can help :)

Plus, keep up the good work! I look forward to seeing the final game :D
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 10 Dec 2016, 12:49

Thanks, glad you like it ;)

Well, it couldn't be possible without your help, so I thought you'll be happy to see some progress after so many questions... :lol:

SolarPortal wrote:Have you tried it with an xbox controller or something? as that script was programmed with joypad also.


Of course I've tried... :geek:

SolarPortal wrote:As for the ribbons, are you using your own texture? There was an issue on the ribbon trail back then, that the texture had to be 1D.
This means you can have a 128 texture but it can only be 1px height. Check out the ribbon texture default to see what i mean It might be in the data folder.


Hmm... that's intriguish. Yes, I'm using my on textures, they are .dds images at 256x256px, black with an alpha channel with the texture of the tiremark. I've checked the default trail texture and it's a .png 78x13 px, in grayscale with transparency. The fact that it's grayscale makes me think that I have to change the color in some way.

I will dig on this a lil bit later, as I think the 256x256 texture is not a problem, but I have to check.

SolarPortal wrote:Plus, keep up the good work! I look forward to seeing the final game


This is a game I've started long time ago and spent millions of hours working on every aspect: design, modeling, programming, etc. It was close to finish but the game engine I was using had some limitations and it was very hard to manage everything, specially at the end. So I'm trying to port my game to Skyline and see how far I can get.

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby StarFire » 10 Dec 2016, 15:28

So I'm trying to port my game to Skyline and see how far I can get.


We hope you can make it all the way. Any snags then we will be there to the rescue and ensure(try our best) you can get your game completed :D
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1419
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: Vehicle setup

Postby SolarPortal » 10 Dec 2016, 20:53

Its fantastic work, so we want to see you succeed to see the engine succeed :D

Onto the problem at hand:
As you say, the image is not a "n" px by 1px image. lol :P
I checked the ribbonDefault in the data folder and this was a 1px high image, so that was the one i remembered .. oops.. haha.

So, i managed to make it onto Gen1(Free Version) today and had a play around on the player vehicle script. I noticed that the textures look more modulative with the colour than additive. So i increased the brightness on the "Car_Tire_track_blur.png" to closer to white and then reloaded the texture in the asset manager. It now made more sense as applying a colour to the brighter texture allowed a better control of the colour and the colours were more vibrant that dull.

If your tread texture was quite black, then any colour you apply will be dark also. So simply increase the brightness on your texture and then use the code line to change the colour as you expected :)
Code: Select all
ribbon.setInitialColour(ribbonID, 1.0, 0.0, 0.0, 0.0);


Hope this helps :D
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 11 Dec 2016, 00:00

StarFire wrote:Any snags then we will be there to the rescue


Thank you! :oops:

SolarPortal wrote:If your tread texture was quite black, then any colour you apply will be dark also. So simply increase the brightness on your texture and then use the code line to change the colour as you expected


Ahh, that makes sense... I've changed the texture to white and certainly have more control, although it needs some tweaking to get the specific tone, will try tomorrow if I have time. Thanks for the tip! ;)

I wanted to try some madness and added 12 AI cars to the track... now it's a lot of fun :lol: And this was just a test, not even had a look at the AI car script, just changed the path name and voilá... I'm loving this engine! :shock:


My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby StarFire » 11 Dec 2016, 00:33

That is great news, we are happy Skyline is is making you smile :D
Your level looks great fun :D
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1419
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: Vehicle setup

Postby SolarPortal » 11 Dec 2016, 01:17

thats advanced quickly. nice one! :)

Waiting for the next video now lol :P
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby lordalmighty1 » 11 Dec 2016, 02:25

that looks cool :D nice work so far
have fun stay safe wot
rig NVidia i7 950 quad core @ 3.07 gtx1060 3gb gddr5, 12gb ram 1600mhz 120ssd 1tb hdd 1tb ex-hdd win10 pro 64bit
rig AMD A8 7650K Quad Core @ 4.0, gtx750ti boost 2.0 2gb gddr5, 16GB DDR3 1600MHz RAM 1tb hdd win10 pro 64bit
User avatar
lordalmighty1
Skyline Moderator
Skyline Moderator
 
Posts: 441
Joined: 02 Jan 2014, 12:13
Location: uk
Skill: Great creative
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 12 Dec 2016, 19:07

Hi there,

struggling with the GUI system, I've added some numbers running... :) I've built a basic timer which starts with a trigger in the finish line. It was a little bit of pain, but finally worked very well.

I've realized that I need to solve the metrics before continuing, as it is the basis of the gameplay. Still need to figure out how to make a racetracker. The lap counter is easy, but calculating the ranking position of each car during the race is gonna be the hell, I guess. I'm thinking on waypoints with triggers and then sorting the results of each car by time... hope you guys can give me a hand on this, at least in terms of organisation and logic.

SolarPortal wrote:Waiting for the next video now lol :P

here you go:



Did I already tell you I'm loving this engine? :lol:

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby SolarPortal » 12 Dec 2016, 19:33

The track is moving along quickly :)

Aahh, Gui's... These are awkward due to having to script them but still doable as you have seen. In between other tasks i am trying to create a GUI Visual editor for gen2 to improve this feature.

Now onto the other bits...

RaceTracker: You know what, i am not quite sure myself yet as we haven't got that far yet... lol :P Will do some research and catch myself up a bit on that.

I do know that you want to use a scenescript for handling the tracking of all vehicles as that will be easier.
Using an AI Sensor or trigger, you could call the scene script publicFn or call a unique function passing trigger id and vehicles passed, and as you say, do the calculation based on that. It means you will need frequent triggers for it to seem real time though otherwise it will only update every so often.

Another way you could handle the ranking is using the spline path that you already have available to you for the AI, you could store on each vehicle the path node that it is currently next too. Since a spline path node system is incremental, you could easily tell who's in what order by the node they are with plus the node counter resets to 0 at the start of the path. Quite simple really... Then use the lap counter as a final thing to take note of those with higher node positions but lower amount of laps. This would be the easiest and you can use these functions:

On line 82 of the "Car_AI_00_Racetrack.lua" file has this line:
Code: Select all
vehicle.followPath(vehID, pathName, throttle);


This actually returns the node the vehicle is currently at, so theres 1 part of the problem solved.
Code: Select all
 currentNode = vehicle.followPath(vehID, pathName, throttle);


Then you could call through to the sceneScript to let the system work out the order using:
(VEHICLE AI SCRIPT)
Code: Select all
   
   nodeIndex = 1;
   entity.callFn(obj,-9,"updateTracking",nodeIndex); -- -9 is the sceneScript


(SCENE SCRIPT)
Code: Select all
function updateTracking(vehicleEID, nodeIndex)
   lprint("vehicleEID: "..vehicleEID);
   lprint("nodeIndex: "..nodeIndex);
end


I hope this gives you a headstart and shouldn't take long with this method.
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby planetX » 12 Dec 2016, 20:02

Oh man, this is pure gold... I have been thinking two days on how to handle this and you make it so simple... :lol:

I'll have a look at this as soon as I can, thank you very much for support, as always. :)

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby planetX » 18 Dec 2016, 19:15

Hi there,

made some progress on the racetracker, still lot of things left to do... I have the lap counter running and the wrong way detection almost done. I've also built a minimap which shows the location of the car in the track. That one was easy, just 4 lines of code. :)



I'm still thinking how to approach the standing calculation, as the example above from SolarPortal only works for AI cars. But I don't feel stuck, I think I can manage... just need time.

In order to track the player car, I've created an array of triggers via script, added a script to each one and assigned an index in a global variable. Every trigger returns a collision hit and the waypoint ID. Everything works fine, except the fact that the script is sending the collision twice, I don't know why (you can see in the console window that the ID is sent twice).

This is the code I wrote to create the waypoints:

Code: Select all
-- Create the waypoints
   for i=0,lastNode,5 do
      wpx,wpy,wpz = path.getNodePosition(pathName, i);
      nodeYaw = path.getNodeYaw(pathName, i);
      waypoint[i] = entity.spawn("node",wpx,wpy,wpz,75,20,0.01);
      --entity.setVisible(waypoint[i],0);
      entity.setRotation(waypoint[i],0,nodeYaw,0);
      if (i == 0) then
         entity.setMaterialName(waypoint[i], "node_red");
      end
      physics.addTrigger(waypoint[i],1);
      sky.setVar("wpID",i/5); --set global var for each script
      entity.addScript(waypoint[i],"MR_trigger.lua");
   end



And this is the external script I've added to each waypoint:

Code: Select all
obj = 0;
wpID = 0;

function onInit(objID)
   obj = objID;
   wpID = sky.getVar("wpID");   
end

function onTrigger_Enter(HitID)
   tagname = entity.getTagFromID(HitID);
   if (tagname == "player") then
      -- set global variables
      sky.setVar("Collision",1);
      sky.setVar("waypointID",wpID);
      sky.lprint("Waypoint: "..wpID);  --  <-- HERE IS THE DOUBLE PRINT
   end
end

function onUpdate( td )
   -- set global variables
   sky.setVar("Collision",0);
end


Any clue? :oops: I was thinking that maybe the car is made by two objects with the same name making collision (body and wheels) but I have no idea how to check the physics body... that's another question I had: how can I setup a custom physics mesh for the vehicle collision? or at least how to visualize it.

Thanks in advance! :)

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby StarFire » 18 Dec 2016, 19:32

very impressed :D
Oh wow minmap, beat us to it lol

The vehicle is made of 2 parts, therefore 2 collisions. You could just filter out the 2nd collision.

To visualize the physics, check the debug physics option in the scene setting panel.

Keep up the good work :D
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1419
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: Vehicle setup

Postby SolarPortal » 18 Dec 2016, 19:43

Colour me impressed! 4 lines of code for the minimap... i gotta see how you did that as it works very well :lol:

As starfire says, there is 2 collisions due to 2 physics bodies. You can change each physics shape scale and position from the .car file usually found at the top, you can even add more bodies if needed. Sadly there is no way to change the name and it was one of those jobs to fix with the double collision. I used to get around it by ignoring the second collision :)

This game is shooting ahead and looks better each time i see it. Great work! :D
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3116
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Vehicle setup

Postby epsilonion » 18 Dec 2016, 19:45

Bloody hell you have gotten that together very fast..

Looks impressive
User avatar
epsilonion
Skyline Moderator
Skyline Moderator
 
Posts: 822
Joined: 26 Feb 2015, 11:51
Location: East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Vehicle setup

Postby planetX » 18 Dec 2016, 20:55

Hi, thanks a lot, glad you like it! ;)

Here's the minimap thingee:

Code: Select all
TerrainSize = 1500; --size of the terrain in meters
MapSize     = 350;  --size of the map in pixels
DotSize     = 15; --size of the dot in pixels
MapRatio    = TerrainSize/MapSize;

function onUpdate( td )
   cx,cy,cz = entity.getPosition(CarID);
   final_car_x = (cx/MapRatio)+(MapSize/2)-(DotSize/2);
   final_car_z = (cz/MapRatio)+(MapSize/2)-(DotSize/2);
   gui.setPosition(guiID,"map_player",final_car_x,final_car_z);
end


This is the markup of the GUI object:

Code: Select all
<div id="map_container">
    <div id="map">
        <img src="map_01.dds"  style="width: 100%; height: 100%;" />
    </div>
    <div id="map_player">
        <img src="map_player.dds"  style="width: 100%; height: 100%;" />
    </div>
</div>


And the css:

Code: Select all
#map_container {
   position: absolute;
   bottom: 0;
   width: 350px;
   height: 350px;
}

#map {
   z-index: 1;
   position: absolute;
   bottom: 0;
   left: 0;
   width: 100%;
   height: 100%;
}

#map_player {
   z-index: 2;
   position: absolute;
   bottom: 0;
   left: 0;
   width: 15px;
   height: 15px;
}


Just keep in mind that the boundaries of the image must match the boundaries of the terrain model. This only works with custom terrain models, but maybe you can find a way to implement it with the native terrain. Hope it helps! ;)

About the collision thing:

Well, I should have asked before... thanks for the input on physics bodies, now I understand everything. But still I'm wondering how can I get rid of the second collision... you say so like it was quite simple but I have no idea how to do it. In the car file, I have these lines:

Code: Select all
CHA1 2.9 1 7.3 0 0.8 0
CHA2 1.6 0.8 2.5 0 2.7 0


Should I just delete one of them?

My specs: Windows 10 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 16 Gb ram DDR4 - NVIDIA GeForce GTX 960M 4 Gb

planetX
Skyline Mage
 
Posts: 208
Joined: 28 Nov 2016, 18:27
Skill: 3D Modeller
Skill: Level Designer
Skill: Concept artist
Skill: Great creative
Skill: Programmer

Re: Vehicle setup

Postby TattieBoJangle » 18 Dec 2016, 21:04

amazing work :D thanks for sharing the script very kind of you :D
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Skyline Grand Master
 
Posts: 845
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Next

Return to Physics

Who is online

Users browsing this forum: No registered users and 1 guest