Hello, I wonder if is it possible to Attach entity using AttachEntityToEntity
to closest bone or a bone player is standing on? For example I would like to attach player ped to vehicle roof / vehicle trailer the player is standing on.
I guess the touching part can be done with IsEntityTouchingModel
IF itâs exactly possible to detect the âclosest boneâ iâm not sure though,
But i do have an example which uses bones in one of my scripts:
And in this post of mine it shows some extra bones information:
The " Player Bones (To attach objects to)" section
Indeed this is possible, but i SUSPECT you would still have to âspecifyâ an array/table of supported models, just ârandomlyâ attaching to âpossibly everythingâ wonât go âthat wellâ i suppose (Not 100% certain though, so donât ânail me to the crossâ for it .
Reason for giving the link to my RideAnimals script btw is that even that iâm still using the same bone(s), it still needs an offset to properly put the player on different animals
Yeah you said about getting player bone thats not a problem, my point is to be able to attach player to a roof of a vehicle (and getting that vehicle bone there is a problem) to dont fell off while vehicle is moving, anyway ill try something
Doing that (if you want to have it permanently) can âeasilyâ be done in vehicles.meta
by adding a tag
This for example is a flag setting for one of my own Stockade mods:
<flags>FLAG_BIG FLAG_NO_BOOT FLAG_AVOID_TURNS FLAG_DELIVERY FLAG_PEDS_CAN_STAND_ON_TOP FLAG_DAMPEN_STICKBOMB_DAMAGE FLAG_DONT_SPAWN_IN_CARGEN FLAG_USE_FAT_INTERIOR_LIGHT FLAG_IS_BULKY FLAG_BLOCK_FROM_ATTRACTOR_SCENARIO FLAG_FLEE_FROM_COMBAT</flags>
Notice the: **FLAG_PEDS_CAN_STAND_ON_TOP **
And via script:
GetEntityBoneIndexByName()
This could help. Iâve used it in my spotlight script - https://github.com/FAXES/Spotlight
Never heard of that, but I will try something. Anyway adding that to like 30 vehicles may be pain in the ass hehe.
GREAT suggestion actually indeed!,
Will be but be much less âissuesâ INGAME, since when you want to be able to put multiple people on one vehicle for example you will need to make sure they wonât clip.
And if you donât want multipleâs ontop you will need to make a check to see if there isnât anyone else ontop (not that big of a deal though, done it in my animals script to).
But keep in mind that that flag also makes it more ârealisticâ and normal behaviour, âattaching playersâ to roofs will also FORCE them to stay on when the vehicle flips (and thus clipping through the ground and such)
Iâve had to do several handlings and ragdoll stuff to overcome that with the animal script
Wow nice, so as I see this could be easily done by attaching only for chassis
for example and should work for every vehicle i guess, another thing is how to get player position and attach it to the exact same spot player is standing? (example: if player is standing on the back of a trailer / vehicle attach him on the back, even getting closest vehicle this could not be done to check if is in front or not right? I dont want to put a specifed place and attach only on center or something
Calculating an offset between the player location and vehicle location, but then you would still have a âsmall problemâ since âbig vehiclesâ have a different âoffsetâ compared smaller/lower vehicles.
Take a look at the spotlight script as that has a few things, as well as through my GitHub.
@Sandacz definitly recommened to do so indeed
AND if you need examples on how to handle it when the vehicle or so âflipsâ (and make the player fall/ragdoll off it), just use the examples in my animals script where i check on the animal dying, getting hit by a car etc
@FAXES see that you used GetEntityForwardVector
but how to use it properly to check if im on front of a vehicle or on a back? And @VenomXNL when the vehicle flips i will try to use GetEntityRoll
and IsEntityUpsidedown
Indeed those will do about the same as i did
Maybe you can do some offset calculation from vehicle location, forwardvector and heading? (just some âtop of my head ideasâ)
GetEntityForwardVector()
gets the forward vector, so which way the ped is facing. It does not set it only gets
Wasnât referring to setting it though (IF you meant my message ), but to use those (together) in some âmixâ to create a detection on where the player is located on the vehicle.
I KNOW/bet there are better methods though (just havnât worked on it myself since working through other aspects of the server first atm), but i have seen scripts coming by which detected if the player is near the trunk or boot for example (sorry no example now, but i guess it should be possible and not âthat hardâ to do then)