#I need more than that.
1 messages Β· Page 1 of 1 (latest)
sorry, wasn't really wanting to post the full script if I could help it. It's messy and crude, plus I'm not particularly good at programming in enfusion / c++ π
I thought just having the function where the change happens and knowing that needed to replicate somehow would have been enough to troubleshoot
Why are you specifically doing it like this as opposed to some other way?
Because I don't want to specify known objects or create an item for every possible object I want to be able to change to
So rather than having a wearable item for 100s of things, I'm just changing the mesh object of 1 item
Not having much experience, as well as figuring it out as I went along, this seemed like the best way
Which it mostly works as I want it to just not when I add remote players into the mix which I hadn't considered being an issue for changing the mesh object (I assumed that the rplcomponent just replicated the entity to everyone automatically)
Where are you recreating the physics of the item?
I'm not.. should I be?
It's basically using your extra slot 3 base prefab, with a starting mesh object, but then changing that mesh object at runtime
I'm not changing anything else physics wise or collider wise, and didn't intend to (I know it still keeps the original collider)
Not sure how this is working correctly for you. If I change the mesh of a shirt that the player has on it loses its weighting.
If you just change the mesh of that shirt, do remote players see that mesh change?
And I'm not actually bothered about the weights or animations of the item changing, it just needs that mesh object change to be visible to everyone because currently it stays as the original item to them but locally the new mesh
By working correctly for me, I just require it to change the mesh object itself, which it does but not remotely
Basically, it's prop hunt ish
My worn item will change into the mesh object of something I choose that isn't an item of clothing. Think a barrel or cardboard box. The item is always worn in an extra slot, then changes its mesh to something new. So it isn't needing animations or weights to transfer / change to a new mesh
I can't join this currently, not at my pc anymore π (11 20pm here so need my sleepπ)
I can DM you a video tomorrow of how it's working currently and the issue I'm having if you need? I do appreciate you willing to look through / discuss though
If you just use a user action all of your problems will go away.
Don't suppose you have an example? I did kinda look into that but couldn't figure it out properly
I do spawn a helper object which could probably hold the user action
Does user action automatically update everyone with whatever the action does?
PerformAction is called on the server and client
This was done with a user actions and it replicates without the need for rpc calls
Nice, that would save a lot of headaches
Seems like it should be fairly easy to move the functionality I have over to an action
Yes and eliminate the need for 90% of it
UserActions are easy, and I would recommend learning how they work first when you're a learning scripter.
Think I initially tried doing it all through them before, but before I went with a helper object, which made things a bit harder to get working whilst learning all the rest of it
So I ended up with this which worked great up until I found out it doesn't automatically replicate π I'll have a play about with the actions again tomorrow now I have all the other bits in place
Depending on the other bits, you probably don't need them.
Init- get the meshobject of the owner
CanShow - check to see if they have an item equipped in the slot you want to change, return if the item is null or not.
PerformAction - get the item in the slot and change its mesh to the owners mesh object.
GetActionNameScript - retrun true and set outName to whatever you like (do this from script so you don't have to do it manually in the actionmanager.
return*
Create a base prefab, GenericEntity >MeshObject>RigidBody>ActionsManagerComponent>RplComponent
give it the correct settings in its rigidbody and add the action to the action manager.
Inherit from the base prefab for all others, they should contain a mesh and be named accordingly
Thanks for the breakdown, I'll take a look today at modifying what I have
this still isn't doing it for remote players, and now the actual functionality / action only shows and works on the server host too :/
fixed the remote player functionality, but it still isn't updating the model to everyone else
@atomic fern You don't need the component at all
So just do everything through the action when the action is spawned?
I explained above exactly what to do.
class ZEL_ChangeUserAction : ScriptedUserAction
{
VObject m_Mesh;
//------------------------------------------------------------------------------------------------
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
{
m_Mesh = pOwnerEntity.GetVObject();
if(!m_Mesh)
return;
}
//------------------------------------------------------------------------------------------------
override bool GetActionNameScript(out string outName)
{
outName = "Change Model";
return true;
};
//------------------------------------------------------------------------------------------------
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
SCR_CharacterInventoryStorageComponent storage;
storage = SCR_CharacterInventoryStorageComponent.Cast(pUserEntity.FindComponent(SCR_CharacterInventoryStorageComponent));
storage.Get(16).SetObject(pOwnerEntity.GetVObject(), string.Empty);
storage.Get(16).Update();
}
//------------------------------------------------------------------------------------------------
override bool CanBeShownScript(IEntity user)
{
SCR_CharacterInventoryStorageComponent storage;
storage = SCR_CharacterInventoryStorageComponent.Cast(user.FindComponent(SCR_CharacterInventoryStorageComponent));
return storage.Get(16);
};
}
This is the exact implementation I explained.
so new issue, the action only shows itself to the server local host and not to the peer tool client unless the server local host has the action visible themselves
the action itself is on a helper entity which gets spawned when specific conditions are met from a component on the character_base.et:
{
if(help == null)
{
Resource res = Resource.Load(material);
EntitySpawnParams param = EntitySpawnParams();
param.TransformMode = ETransformMode.WORLD;
entity.GetWorldTransform(param.Transform);
param.Transform[3] = pos;
// Print(param.Transform[3]);
help = IEntity.Cast(GetGame().SpawnEntityPrefab(res, entity.GetWorld(), param));
// Print(entity);
// Print(help);
}```
using SpawnEntityPrefabLocal prevents the action working completely
so with a local helper I need to have this in the action
override bool HasLocalEffectOnlyScript()
{
return true;
}
but this then stops the action being seen by the server again back to square 1. When not having the helper "local" the action does broadcast to everyone and the model change is seen but the action will only show up if the local server host has the action up themselves π€
they do, I think I found an issue which is causing the action to not show up.
Attempt to spawn a replicated prefab propHelper [RplComponent] blocked. Allowed server-side only!
the client isn't allowed to spawn the helper entity containing the action, so they never see the action
yeah so I need to wrap the helper function in a server call I guess, and have the client ask to spawn that?
SpawnEntityPrefab has to be called by the server
it does nothing if called from client except spit out that message
Attempt to spawn a replicated prefab propHelper [RplComponent] blocked. Allowed server-side only!
I see, but SpawnEntityPrefabLocal then stops the action on that entity actually doing anything. So would I need to do something like this? Call askSpawn
{
Rpc(spawnHelper());
}
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
void spawnHelper()
{
SpawnEntityPefab
}```
SpawnEntityPrefabLocal doesn't spawn a replicated entity
action manager component only works on replicated entites
Just have the damn server spawn the item
yeah that's now what I'm trying to do, as I didn't realise it wasn't doing that in the first place
class ZEL_SpawnUserAction : ScriptedUserAction
{
ResourceName m_PrefabPath = "{FFF30795991DC01C}Prefabs/Rocks/Granite/Rock.et";
//------------------------------------------------------------------------------------------------
override bool GetActionNameScript(out string outName)
{
outName = "Spawn Rock";
return true;
};
//------------------------------------------------------------------------------------------------
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
if(!Replication.IsServer())
return;
Resource LoadedResource = Resource.Load(m_PrefabPath);
if(!LoadedResource)
return;
IEntity Rock = IEntity.Cast(GetGame().SpawnEntityPrefab(LoadedResource));
if(!Rock)
return;
vector WorldTransfrom[4];
pOwnerEntity.GetWorldTransform(WorldTransfrom);
Rock.SetWorldTransform(WorldTransfrom);
Rock.Update();
SCR_EntityHelper.DeleteEntityAndChildren(pOwnerEntity);
}
//------------------------------------------------------------------------------------------------
}
i'm going to have to look into a better way than what I created I think, your action stuff has helped loads and now I need to handle the spawning of the helper a different way to what I did originally. I've found out that trying to make the client ask the server to spawn that when using the action, it has loads of null pointers now because it seems to be trying to take what the server has stored rather than the local values on the client
Basically I currently use this GetCursorTargetWithPosition, store the cursor target class name and check if it contains x with propObject.Contains("GenericEntity") and then if that's found I check the distance between player and cursortarget before calling the spawn function for the helper object at that cursor targets location
So it's all dynamic and can't be controlled via an action to spawn the helper object itself :/
There is no need for any of that. I gave you the two actions that you need.
does your second action not require knowing in code what object to spawn?
To spawn something you have to know what it is....
Not quite sure why you're doing anything requiring the cursor or it's position
Are you trying to make prop hunt or something?
pretty much, I need the helper entity to spawn on the object if that object meets specific criteria, but the helper needs to be spawned through the server like you said though this can't be done via another action to spawn as it's all dynamic
it works apart from replication, due to the helper entity thing not being allowed to be created by the client (which i hadn't realised whilst testing in workbench originally)