Page MenuHomeFeedback Tracker

Snap a placement position to another object
New, UrgentPublic

Description

Hello, I'm a beginner mod maker. I've been doing this for almost a year now and have studied the game code well. But I just can't solve one problem: how to bind the placement of an object to another object. For example, a bomb in the middle of the fence. The code I wrote:

class ActionActivateBoomSystem: ActionDeployObject
{

	override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
	{	
		if ( !GetGame().IsMultiplayer() || GetGame().IsClient() )
		{
			if ( player.IsPlacingLocal() )
			{
				if ( !player.GetHologramLocal().IsColliding() )
				{
					EntityAI targetEntity = EntityAI.Cast(target.GetObject());
					if (targetEntity)
					{
						if (targetEntity.IsKindOf("Fence")	
						{
							return true;
						}
					}
				}
			}
			return false;
		}
		return true; 
	}
	override bool HasTarget()
	{
		return true;
	}

}

I want the hologram of the placed object to automatically snap to the center of the fence the player is looking at, rather than being placed on the ground. My object inherits from landminetrap. I would add more code, but I tried to override so many functions that I ended up confused and erased everything.

P.S. for 2 days of wandering in action files, I got completely confused.

P.P.S Sorry for Google Translator.

Details

Severity
Trivial
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

mate26 created this task.Nov 18 2020, 11:33 AM
mate26 updated the task description. (Show Details)
mate26 updated the task description. (Show Details)Nov 18 2020, 11:39 AM
komer added a subscriber: komer.Nov 18 2020, 5:11 PM

to implement what you need, you just need to use these functions:
ModelToWorld
WorldToModel
RaycastRV

I also hope that you redid the hologram function, since there, according to the standard, cliped on the object is disabled, only on the surface of the object is enabled.

Google Translator.