Jump to content
sarogahtyp

Reference to an existing entity / even if an BI map object / hide map objects

Recommended Posts

I try to find a method to

1. reference to any object out of a script tied to another entity.

 - f.e. i have a truck named SaRo_BMHQ_Hillbilly01 and I want to hide a camo net which is not named but which is ordered below the truck in the Hierarchy:

 

CDyPQxq.jpeg

 

- I need to know how to reference the camo net out of a trucks event script.
 

2.  - How to hide that camo net generally

 

3. - How to first reference and then hide an AR map object using the EOnInit event handler of the game mode entity (or maybe there is another better init method?).

Share this post


Link to post
Share on other sites

I am no expert but have been trying to do similar things, here are some things I have learnt so far:

Checkout:

1) Action scripts:  https://community.bistudio.com/wiki/Arma_Reforger:Action_Context_Setup

2) In the workbench script editor search for UserActions, there are lots of examples. TestPushUserAction : PerformAction uses the SCR_InteractableBoxComponent

2)  Add SCR_InteractableBoxComponent to your prefab, which can be used to do more complex actions and events but you could just use a simple action script

You can find it from the action script using this code:

GenericEntity genEnt = GenericEntity.Cast(pOwnerEntity);
AM_InteractableBoxComponent boxComponent = AM_InteractableBoxComponent.Cast(genEnt.FindComponent(AM_InteractableBoxComponent));
			
if (boxComponent)
{
	boxComponent.CancelDragAction();
}

 

3) You can view the script for each component by right clicking on it
 

4) You can spawn a new entity also with this code, disclaimer I am not sure about the rpl stuff,  still learning at the moment?:

	//------------------------------------------------------------------------------------------------
	private void SpawnEntity( string entityString )
	{
		// Server obj
		//if (m_rpl.IsMaster())
		//{
			VObject obj = m_Owner.GetVObject();	
		
			vector objectPosition = m_Owner.GetOrigin();
					
			Resource resource = Resource.Load( entityString );
			//Resource resource = Resource.Load("{FD7FC6D54771949A}Prefabs/Weapons/Warheads/Warhead_Smoke.et}");		

			IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
			
			//~ Spawn at ground or sea position
		    EntitySpawnParams spawnParams = new EntitySpawnParams();
		
			objectPosition = objectPosition + "0 0 1";
		
		    spawnParams.Transform[3] = objectPosition;
  
		    SCR_Global.SnapToTerrain(spawnParams.Transform, GetGame().GetWorld(), true);
		       
			//~ Apply scale from prefab
		    float scale;
			entitySource.Get("scale", scale);
				
			if (scale != 1)
				{
					SCR_Math3D.ScaleMatrix(spawnParams.Transform, scale);
				}	            
		        
	        GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
		
			m_Owner.SetOrigin(objectPosition + "0 0 2");
		//}
	
	}

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×