User Tools

Site Tools


attach_points

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
attach_points [2020/09/26 20:57] justinattach_points [2022/05/09 15:06] (current) justin
Line 5: Line 5:
  
 =====Creating Attach Points===== =====Creating Attach Points=====
 +Attach points for models can be created with the "Create Attach Point" tool in the [[Voxel Editor]]. This tool can be selected using the shortcut key of "F8" or by clicking on the tool button with the "link" icon on the Model Tools panel. While active, left-clicking a voxel will place an attach point at that coordinate. The attach point's location can be adjusted later using the offset sliders (see next section).
  
-Attach points for models can be created with the "Create Attach Point" tool in the [[Voxel Editor]], using the shortcut key of "F8" or by clicking on the tool button with the "link" icon on the Model Tools panel. With this tool active, left-clicking a voxel will place an attach point at that coordinateIts location can be adjusted once added using the offset sliders (see next section). +After left-clicking a voxel, the editor will prompt for an attach point IDEach attach point within a model frame must have an ID that is unique to that frame. Once added, a white cube with a "linkicon will be displayed at the new attach point's location.
- +
-Attach point ID is unique per model frame +
- +
-White cube with link icon will display at attach point positions+
  
 <WRAP center round info 100%> <WRAP center round info 100%>
Line 21: Line 18:
  
 =====Offset, Rotation, and Scale===== =====Offset, Rotation, and Scale=====
- 
 There are several properties that can be adjusted for attach points from the [[Model Properties]] panel: //offset//, //rotation//, and //scale//. These properties affect an [[object|object's]] appearance when attached to that particular attach point. The settings for these properties can be assigned per frame, allowing attached [[object|objects]] to be animated along with the parent model. There are several properties that can be adjusted for attach points from the [[Model Properties]] panel: //offset//, //rotation//, and //scale//. These properties affect an [[object|object's]] appearance when attached to that particular attach point. The settings for these properties can be assigned per frame, allowing attached [[object|objects]] to be animated along with the parent model.
  
Line 30: Line 26:
  
 =====Scripting with Attach Points===== =====Scripting with Attach Points=====
 +Once you've set up any necessary attach points for your [[object|objects]] and the models to which they will be attached, you can use the [[Attach Object]] scripting function to trigger an [[object]] to be attached to a target [[entity]] in-game, for example to attach a torch to a wall tile when the player interacts with it.
  
 +The example below will attach the "sword" [[object]] model's "handle" attach point to the player's "right_hand" attach point.
 <code bauxite> <code bauxite>
-attach_object("sword", player, "handle", "right_hand")+attach_object("sword", player, "handle", "right_hand");
 </code> </code>
  
 +Alternately, you can create attach points for the sword [[object]] and player [[character]] using the same ID (e.g. "hand") and leave out the function's fourth parameter.
 <code bauxite> <code bauxite>
-attach_object("sword", player, "hand")+attach_object("sword", player, "hand");
 </code> </code>
  
 +To detach a previously attached [[object]], you can use the [[Detach Object]] scripting function, for example to remove a book from a table when the player interacts with the table.
 +
 +The example below will detach the [[object]] currently attached to the player's "right_hand" attach point.
 <code bauxite> <code bauxite>
-detach_object(player, "right_hand")+detach_object(player, "right_hand")
 +</code> 
 + 
 +You can reference the [[object]] that's currently attached to an attach point using the "attachment" property with the desired attach point ID. In the example below, the "glow" [[animation]] will be played for the [[object]] attached to the player's "right_hand" attach point. 
 +<code bauxite> 
 +play_animation(player.attachment["right_hand"], "glow");
 </code> </code>
  
 =====Equipment===== =====Equipment=====
 +Although most of the equipment system is yet to be implemented, there is some experimental functionality that can be used to automatically attach models to a character whenever an item is equipped. The steps below can be followed to create an equippable item with a corresponding [[object]] model.
  
-Automatic attaching based on attach point ID when an item is equipped and an object model is assigned to that item)+1) Toggle the "Equippable" setting to "On" for the [[item]] in the [[Item Editor]].
  
-Steps to follow:+2) Assign an [[object]] model to the [[item]] in the [[Item Editor]].
  
-- Toggle "Equippable" to "On" for the item in the Item Editor+3) Create an attach point for both the [[character]] and [[object]] that matches the equipment slot ID (e.g. "right_hand").
  
-- Assign an "Object Model" to the item in the Item Editor+4) Call the [[Equip Item]] scripting function to equip the [[item]] to the appropriate slot (e.g. "right_hand") and the [[object]] will automatically be attached to the corresponding attach point.
  
-- Create an attach point for both the character and object that match the equipment slot ID (e.g. "right_hand")+<code bauxite> 
 +equip_item(player, "right_hand", "ITEM_0001")
 +</code>
  
-- Call "equip_item" scripting function to equip the item to the appropriate slot (e.g. "right_hand"and object will automatically be attached to the corresponding attach point+With this setup, calling the [[Unequip Item]] scripting function will automatically detach the [[object]] model associated with the [[item]] that is unequipped. 
 + 
 +<code bauxite> 
 +unequip_item(player, "right_hand")
 +</code>
  
 ~~NOTOC~~ ~~NOTOC~~
attach_points.1601179038.txt.gz · Last modified: 2020/09/26 20:57 by justin