#current player vehicle
1 messages ยท Page 1 of 1 (latest)
This depends on the context you are in. Where did you want to put the code to control this?
ignore the first part
SCR_CharacterCameraHandlerComponent
this code right now disables forces 1p when player isnt in vehicle
I would like to modfy it so it dorces 1p everywhere expect in btr and mi 8
my final goal is to only allow 3p on commander and navigatoe seat but I dont even know if that is possible and how much modding it would require
okay, that is doable ๐ but I am afraid for today my mental capacity is exhausted. Some general pointers would be to get the parent vehicle, probably available on either the char controller or the character itself you can get from it.
then you can check for the parent prefab and so some whitelisting.
you can also get the seat a person occupies for sure if you have the player and vehicle entity.
I can give you a few method names tomorrow if you want to wait, otheriwse feel free to look at the script apis you have from the char controller and see where you can navigate from there to get entities and additional components ๐
@deft night
modded class SCR_CharacterCameraHandlerComponent
{
override int CameraSelector()
{
if (IsInThirdPerson() && !m_OwnerCharacter.IsInVehicle())
{
SetThirdPerson(false);
return CharacterCameraSet.CHARACTERCAMERA_1ST;
}
if(m_OwnerCharacter.IsInVehicle())
{
CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
IEntity vehicle = compartmentAccess.GetVehicleIn(m_OwnerCharacter);
if(vehicle.GetPrefabData().GetPrefabName().Contains("Mi8"))
{
SetThirdPerson(true);
return CharacterCameraSet.CHARACTERCAMERA_3RD_VEHICLE;
}
}
return super.CameraSelector();
};
};
thank you
but I dont think this is a good solution id I want to target the seat or?
i've just made you a simple solution to get started. You can do whatever logic you want after you get the vehicle.
๐ซก
ok so I changed the code a bit it works great
excatly what I wanted now just to figure out the seat
this is what I found for seats
I guess if I could check if player is in passenger_r01 it could work
or would this be a bad method?
@shadow crescent did you refuel your mental capacity ๐
Yes. How far did you get with the code posted above from Zelik? What is missing?
To find out what slot your character is in, there is actually an easier way. The vehicle defines what slots are available, but the character knows which slot he entered for script logic such as a gunner HUD etc.
Found on the character prefab
So what you can do is ```cs
BaseCompartmentSlot currentCompartment = compartmentAccess.GetCompartment()
if (currentCompartment && currentCompartment.GetType() == ECompartmentType.Pilot)
// do something
or if you want to do it the other way around you can say != piliot and then apply your restrictions ๐
this is what I have
thank you I will try it
this also works for multiplayer character?
the camera is local for each player. each player knows which slot they are in, so yes.
yes I understand thank you do much
ECompartmentType has only 3 types?
pilot for driver
turret
cargo for passengers
right?
right now yes, this can change in the future so please use an enum value for comparision and not do something like == 1
yes but if I understand correctly I could only chose what happens to camera when the player is driver, turret or passenger? my goal is to limit the 3p in every case expect if he is in commander seat in BTR but commander seat counts as cargo?
also why do you have currentCompartment && currentCompartment.GetType(), couldnt it work just with currentCompartment.GetType()?
probably because you already checked that the player is in a vehicle
if you did not do that this might be null if he is currently not in one and then blow up, so i put it there in case somebody else comes to copy or adapt my message under other conditions
ah ok
but this solution cant work because it would give all passengers 3p
or is there way to be more specific?
your goal was only pilots right?
no, here you go
sorry if my english is bad hahahaha
I want only so commander hast the acces to 3p
not the driver
ahhhh ok, then we can something else
I think commander is passenger_r01
thank you, whenever you have time
shouldnt we in this case use || instead of &&
Okay it looks like in script there is no easy way to tell which slot is the commander one for certain
its not special, its just a passanger seat with a special name on the action but apart from that not much
For vanila vehicles you could note which compartment will be the commander but with mods it might not always be passanger_r01
yes I care only about vanilla BTR commander seat
We will look into this in the future, for now I am not aware of any ways to do what you need to easily. you can only allow thrid person for driver, but comamnder not so easily
I see this sometimes what does it mean do not modify, this script is generated. Where from?
This is from the games code. These scripts only serve as interface between our c++ code and the game scripts. You can not mod them
also could you please clarify this for me, if you have time?
also the game is coded in c ++?
you can not just replace the && by || that makes no sense there. you check for "i have a compartment instance and if so, what type is it". if you have no compartment you do not need to check the type. if you put and or there you have null or null.gettype() which will blow up ๐
Yes anything you see in the game, that is not in the scripts in workbench, is written in c++ as part of the main game executable ๐
thank you
BaseCompartmentSlot currentCompartment = compartmentAccess.GetCompartment()
if (currentCompartment && (currentCompartment.GetType() == ECompartmentType.Pilot))
// do something
so basically this but you dont need the () in this scripting language
it depends on the operator priority. in this case the == comparison on the right will have higher prioprity than the &&
so the code does what you put in () already. but you can always put it if you are not sure about the order
ah I see ok thank you
wouldnt this give me the slot name?
then I could compare it to passanger_r01
you are looking at the wrong component. compartments on vehicle are managed by BaseCompartmentManagerComponent
and there you do not have access to the slot name
you could get the UI info for the slot via compartment.GetUIInfo().GetName() and check that as a workaround maybe
@shadow crescent since all vehicles are of the same class. What is the best way to get if a vehicle is a "Mi8" for instance?
only by prefab. you check if a prefab inherits the one you care about to catch the base vehicle and all derived variants the game or mods might offer from it
@shadow crescent @fickle basin I will probably update the mod only allowing 3p in the BTR driver seat. If you would like a credit for the help just DM your Bohemia email. Thanks for taking your time to help me.
I do not need credits. I am just helping you learning about the game which is part of my job ๐
ah ok
๐
I would still love to find a way to limit the 3p only to the commander seat but I need to focus on other things
still thank you
As I said, try doing the way through UIInfo, it might be the most reliable right now
How would I go about that I don't see a simple way to get the UI, I would guess something like getUI.name or something
i told you here