Jump to content

C# Reference BodyRigid (Physics-Related Classes)


photo

Recommended Posts

Hi,

when using "public BodyRigid nodename" the editor does not show the property field.

ComponentClass supports Node and Unigine.Component and not Physics-Related Classes.

Is there code to validate the node type?
Or to get direct feedback in the editor if the selected .node is not acceptable?

This is my current code, it works and keeps the program from crashing on Init. General help and advise is always welcome.

	public Node bouncing_node;
	private BodyRigid bouncing_body;
	
	private void Init()
	{
		if(bouncing_node)
		{			
			if(bouncing_node.NumChildren > 0)
			{
				var child = bouncing_node.GetChild(0);
				if(child.ObjectBodyRigid)
				{
					bouncing_body = bouncing_node.GetChild(0).ObjectBodyRigid;
				}
			}
		}
	}

	private void UpdatePhysics()
	{
		if(bounce_triggerd)
		{
			bounce_triggerd = false;
			if (bouncing_body)
			{
				bouncing_body.AddForce(vec3.UP * bounce_power);
			}
		}
	}

 

Link to comment

Hello,

At the moment there is no way to check the type of node or that is null in the editor. Now fields are automatically checked for compliance with the type when assigning a node to a component parameter. Therefore, there is only a guarantee that the field will match the type or its inherited types, or that the field will be empty.

Link to comment

So if it is not possible to request BodyRigid directly.

Is it possible to give feedback while still in the editor?
Like

OnValueChange
	Check_value
	if ok
		return
	else
		clear value
		or value color red
	

 

Link to comment
×
×
  • Create New...