![Flan's Mod Ultimate Stability Edition](https://media.forgecdn.net/avatars/thumbnails/228/314/256/256/637049574570422621.jpeg)
(Enhancement) Vehicle Collision Boxes
conman180 opened this issue ยท 19 comments
It may be out of the question, but I have seen other mos incorporate collision boxes that directly interact with players and mobs. Would this be possible for FM+? I have seen this implemented in other mods elsewhere. It would allow for running people/ mobs over if traveling fast enough and being able to move around within vehicles without being in a seat. A lot of large vehicles could benefit from this. An example would be a player standing on top of a tank, or an airliner you could walk around in to get to the seats.
Apologies for delay
I have a suspicion the the collision meshes are directly coded into the models. (I dont know for sure, but i dont have any of the source java models from the pack you gave me the config from.)
the harvestbox feature only interacts with blocks to break them
Even after disabling the harvest box, the collision with the player was still there
no config options turned the feature off.
Hello again, I've done some more investigation - there's two systems.
-
The simple system: It uses standard hitboxes, that you can stand on. The crazy bit - it will only check for player collisions if the player is inside the HarvestBox set in config. Imo this is some crazy mixing of features which.. really shouldn't be done. But that's what it is. So if you just add
HarvestBox [99,43,46] [-36,-10,-23]
, it'll apply collisions to the players in that bounding box. (HarvestBox [sizeX,sizeY,sizeZ] [posX,posY,posZ]). I think the reason for adding this, was for the "Harvest box" to surround the entire tank, so it could be used to determine where to check for player collisions, but also what to be used as a harvester, for ramming trees, removing grass/leaves e.t.c. (Edit: I must stress that FancyCollision should be FALSE for this to work) -
The second system: Collision mesh. I need to investigate this further. (Edit: FancyCollision=true).
I'll also be putting my findings into the wiki.
Okay! Success!
I managed to get the second system working, and here's an extract from the wiki page I've written about it.
2. Fancy method
This requires FancyCollision true
, its default value.
This system is a bit more tricky to use, but is a lot more powerful.
To specify what players should collide with, you create glorified shapeboxes. You still need the harvestbox code from the previous system to specify where to look for collisions.
To add a hitbox, you can use one of the following:
AddCollisionMesh [posX,posY,posZ] [sizeX,sizeY,sizeZ] [p1X,p1Y,p1Z] .. [p8X,p8Y,p8Z]
e.g.
AddCollisionMesh [0, 0, 0] [20, 50, 5] [0, -1, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, -1, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0]
AddCollisionMeshRaw posX posY posZ sizeX sizeY sizeZ p1X p1Y p1Z .. p8X p8Y p8Z
is the same, just with all the values in a long line.
For the turret, use AddTurretCollisionMesh
and AddTurretCollisionMeshRaw
.
The units here are also pixels, (16px = 1 block).
The player will collide with all six sides of this shapebox (IF they are in the harvester hitbox). In FM+USE, you can see the corners of these shapeboxes in debug mod, as particles.
============================
https://github.com/Unknown025/Flans-Mod-Plus/wiki/Player-Collisions
If you've got any other questions or want a sample config, let me know. Hope that helps ;)
Much Appreciated. However , I can only seem to get the simple version working. When I copied and pasted the fancy method , no particles appear in debug mode. Currently running ver1.47.
Side note: the collision system seems to have no effect when applied to a plane config. Only ground vehicles or boats seem to work.
Would you mind posting a sample config and and a screenshot to show what debug looks like with the particles?
Attached is a config of a vehicle Im testing it on
LPM04_AriellaStriker.txt
Ah, apologies. I had to uncomment the particle rendering, so it'll be out in the next update. I can try and get you a build this evening, with that in.
Yup, the system only seems to work for vehicles atm.
Many Thanks. works well. However is it possible for the future to have this implemented for planes as well? I can see a few areas where it could be very helpful.
Great! Glad to hear you've got it working. As for planes - it's probably a matter of copying the code across into the common base type. I can foresee issues with speed/collision detection and weird angles, especially that I don't know what will happen when things turn upside down. Therefore, I'll add it to the to-do list but the priority will have to be low because there isn't huge demand rn, and it may end up being.. quite buggy. But it's worth a shot.
Is it alright if I close this in the meanwhile, given it's settled for the moment? I doubt I'm going to get to adding the collisions anytime soon sadly, but it is on the list.
Hi, I believe this feature exists already. There is both the ability for players to collide with a vehicles normal hitbox, and also a generic collision mesh system, though I haven't tested it - it was written by PrototypeTheta a long time ago. For the normal collision, iirc there's a config you have to enable, I can find it for your if you'd like? Or you can look in the config reference, Ctrl+F and look for collision.
I'm not 100% either feature does full interaction with players, and probably not mobs, but it's a starting point.
I found what you mentioned in the config reference, Ill have to apply them to a vehicle and test them. Ill list my findings in this thread after I've gone through it.
I dont know if the different collision boxes are supposed to render in debug mode or if I am putting them in to the txt for the vehicle wrong. I cant seem to get one into the game. any help is welcomed o the proper formatting.
Sorry for delay
FancyCollison true
Attempt 1, AddCollisionMesh 0 0 0 16 0 0 0 0 0 0 0 0
Following the format stated X Y Z size p1mod p2mod p3mod etc, for each point
Attempt 2. AddCollisionMesh 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
X Y Z size then an X Y Z modification for each point
Attempt 3. Same as 1 but with AddCollisionMeshRaw
Attempt 4. Same as 2 but with AddCollisionMeshRaw
The CollisionShapeBox.java hasnt provided much help either with the exception that it shows it is there to be used.
(Update) : I have also tried what I did above with FancyCollision False. Have also tried to make the size of the box larger to see if it will run into anything.
Hope this helps anything. Not a big deal. I'm more focused on trying to figure out how the flight controller should be rewritten, but that is for a different issue later on.
My memory is that there was a way to just have normal hitboxes have collision, and it's used in GFS iirc. It took me a long time to find, because.. why would a harvester be used for collision?
Harvester true HarvestToolType Tank HarvestBox [99,43,46] [-36,-10,-23]
There's a config, I would guess the two points are the start and end point of the hitbox.
Have a try with that and see if it does what you need, otherwise I can delve into the collision mesh stuff.
As for planes - I started a branch and had a poke around with rewriting the flight model from the ground up, but many other bugs/features have higher priority atm. If you can look at rewriting some of it, that would be extremely helpful - or just sharing drawings/ideas of how you think it should work.
The Harvester function works but not in the way I was thinking. It only interacts with blocks to destroy them. The closest thing I can compare what I'm looking for is the way hit boxes work in the Immersive Vehicles mod for 1.12 They act like a solid block you can walk around on.
weird, I was trying to replicate the collision stuff in one of the BMP vehicles, looks like I got the wrong thing, or messed my testing up somehow..
I know this feature exists and works because I got it working on the abrams in my test environment. I'll send you the config of a vehicle I know has the feature - you can stand on it, walk into it e.t.c. and it seems to be modelled around the vehicle's hitboxes.
The collision mesh stuff is for player interactions, you can see the results in proto's dev videos, from many years ago. I'm pretty sure about that, but not 100% because I haven't looked at the code:
https://www.youtube.com/watch?v=hfgzoUoZlfY
https://www.youtube.com/watch?v=eVavrcIHSx8
https://www.youtube.com/watch?v=hpKfdbJFvws
Here's the config of a vehicle which has that feature, I'm just not sure which config actually enables it.
Scorpion.txt
The Harvester function works but not in the way I was thinking. It only interacts with blocks to destroy them.
The closest thing I can compare what I'm looking for is the way hit boxes work in the Immersive Vehicles mod for 1.12
They act like a solid block you can walk around on.
Maybe the collision mesh part doe this, but I have a feeling it was intended as a way to replace the collision point system for when you crash into things.
For planes- I have some ideas as to how the physics should work as I fly planes IRL but, I wouldn't want them to be so realistic as to make it not easily playable. As for the coding of it, I'm more of a beginner so me writing any of it is probably not a good idea at this point. Ill open an issue once i have a system planned out.
Anyways, thanks for the help