Page MenuHomeFeedback Tracker

[Feature Request] entity parenting
New, UrgentPublic

Description

During development of Ship, I would like when player is linked to this vehicle (LinkToLocalSpace) also all items which drop, craft, whatever, should be automatically added as child to player's parent (ship). Its needed heavy modding a lot of classes. Will be very good have it prepared in vanilla.

Example howto automatically set parent dropped item:

modded class ItemBase extends InventoryItem
{
	
	override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
	{
		super.EEItemLocationChanged(oldLoc,newLoc);
		
		if ( !GetGame().IsServer() )
		{
			return;
		}
		
		if (newLoc.GetType() == InventoryLocationType.GROUND)
		{
			if (oldLoc.GetParent())
			{
				PlayerBase player = PlayerBase.Cast(oldLoc.GetParent());
				if (player)
				{
					if (player.GetParent())
					{
						//hrac je na lodi, je treba vzit polohu hrace vuci lodi
						// pak zmenit item parent na lod
						EntityAI ship = EntityAI.Cast(player.GetParent());
						
						
						vector tmItem[4];
						vector tmTarget[4];
						vector tmLocal[4];
		
						vector pPos = player.GetPosition();
						vector pOri = player.GetOrientation();
		
						player.GetTransform( tmItem );
						PlaceOnSurfaceRotated( tmItem, pPos, 0, 0, 0, false );
		
						ship.GetTransform( tmTarget );
						Math3D.MatrixInvMultiply4( tmTarget, tmItem, tmLocal );
						
						
						SetTransform( tmLocal );

						ship.AddChild( this, -1 );
						ship.Update();
						
					}
				}
			}
		}
	}
}

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General

Event Timeline

Hunterz created this task.Dec 15 2020, 12:57 PM
Hunterz updated the task description. (Show Details)
Hunterz updated the task description. (Show Details)Dec 15 2020, 12:59 PM
Hunterz updated the task description. (Show Details)

You will have to manually do this for every interaction you want to perform. AddChild / LinkToLocalSpace are not part of the normal gameplay and as such would require quite an extensive overhaul of the vanilla scripts.
And since it is certainly possible to achieve this already through modding less than 5 classes (I know cause I did this already), I do not see much priority for this to happen for the official version.

Hmm, but game is still developed. Getting new features and mechanics. Why not parenting to vehicles?

There was mod perishable food, and now is similar mechanic in vanilla game.