User Tools

Site Tools


dragengine:modules:dragonscript:behavior_interactionspot

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
dragengine:modules:dragonscript:behavior_interactionspot [2020/11/23 16:08] dragonlorddragengine:modules:dragonscript:behavior_interactionspot [2025/03/12 20:27] (current) dragonlord
Line 8: Line 8:
  
 ====== ECBehaviorInteractionSpot ====== ====== ECBehaviorInteractionSpot ======
 +
 +<WRAP center 100%>
 +<WRAP center box 450px>
 +{{youtube>BbP-lMrr0tQ?medium}}
 +<WRAP centeralign>Behavior in action (starting at timestamp 1:28)</WRAP>
 +</WRAP>
 +</WRAP>
  
 Behavior element behavior adding support to define interaction spot for actors. Behavior element behavior adding support to define interaction spot for actors.
Line 23: Line 30:
 ====== Element Class Properties ====== ====== Element Class Properties ======
  
-Element class properties have the prefix **interactionSpot.** or **interactionSpot(id)**. if id is not empty.+Element class properties have the prefix ''interactionSpot.'' or ''interactionSpot(id)''. if id is not empty.
  
 ===== position ===== ===== position =====
 Position relative to owner element the actor or player has to be placed at to interact with the owner element. Position relative to owner element the actor or player has to be placed at to interact with the owner element.
   * Full name: “interactionSpot.position” or “interactionSpot(id).position”   * Full name: “interactionSpot.position” or “interactionSpot(id).position”
-  * Type: 3-component vector. Format used with object properties (string): "x y z" +  * Type: 3-component vector 
-  * Default Value: (0, 0, 0)+  * Default Value: ''(0, 0, 0)''
   * Example (*.deeclass) <code xml><vector name='interactionSpot.position' x='0' y='-1' z='0.5'/></code>   * Example (*.deeclass) <code xml><vector name='interactionSpot.position' x='0' y='-1' z='0.5'/></code>
  
Line 35: Line 42:
 Orientation in euler angles relative to owner element the actor or player has to be placed at to interact with the owner element. Orientation in euler angles relative to owner element the actor or player has to be placed at to interact with the owner element.
   * Full name: “interactionSpot.orientation” or “interactionSpot(id).orientation”   * Full name: “interactionSpot.orientation” or “interactionSpot(id).orientation”
-  * Type: 3-component vector. Format used with object properties (string): "x y z" +  * Type: 3-component vector 
-  * Default Value: (0, 0, 0)+  * Default Value: ''(0, 0, 0)''
   * Example (*.deeclass) <code xml><vector name='interactionSpot.orientation' x='0' y='180' z='0'/></code>   * Example (*.deeclass) <code xml><vector name='interactionSpot.orientation' x='0' y='180' z='0'/></code>
  
Line 42: Line 49:
 Position to look at while actor or player is approaching the target position. Typically used together with [[behavior_conversationactor|ECBehaviorConversationActor]] to set the Head Look-At playback. Can be null (or empty string with object properties) to not use a look-at. Position to look at while actor or player is approaching the target position. Typically used together with [[behavior_conversationactor|ECBehaviorConversationActor]] to set the Head Look-At playback. Can be null (or empty string with object properties) to not use a look-at.
   * Full name: “interactionSpot.lookAt” or “interactionSpot(id).lookAt”   * Full name: “interactionSpot.lookAt” or “interactionSpot(id).lookAt”
-  * Type: 3-component vector. Format used with object properties (string): "x y z" +  * Type: 3-component vector 
-  * Default Value: null +  * Default Value: ''null'' 
-  * Example (*.deeclass) <code xml><vector name='interactionSpot.position' x='0' y='0.2' z='0.5'/></code>+  * Example (*.deeclass) <code xml><vector name='interactionSpot.lookAt' x='0' y='0.2' z='0.5'/></code> 
 + 
 +====== Events ====== 
 + 
 +===== spotClaimed ===== 
 + 
 +Occupier has claimed spot. 
 + 
 +===== spotReleased ===== 
 + 
 +Occupier has release spot.
  
 ====== Required Behaviors ====== ====== Required Behaviors ======
 +
 This behavior does not required other behaviors to be present.  This behavior does not required other behaviors to be present. 
  
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
 +
 This behavior does not support optional behaviors. This behavior does not support optional behaviors.
  
 ====== Persistency ====== ====== Persistency ======
-This behavior does support element class to be persistable (setPersistable). Saves [[behavior_occupier|ECBehaviorOccupier]] if present.+ 
 +This behavior does support element class to be persistable (setPersistable).
  
 ====== API Documentation ====== ====== API Documentation ======
-[[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorInteractionSpot.html|ECBehaviorInteractionSpot]].+#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorInteractionSpot.html,ECBehaviorInteractionSpot~@#.
  
-Since DragonScript Module Version **1.4**+Since DragonScript Module Version ''1.4''
  
 ====== Use Cases ====== ====== Use Cases ======
 +
   * Ensure actor/player is at a specific position and orientation relative to an interactive element to ensure animation of actor/player and interactive element properly line up.   * Ensure actor/player is at a specific position and orientation relative to an interactive element to ensure animation of actor/player and interactive element properly line up.
   * Ensure only one actor/player uses an interactive element at each time.   * Ensure only one actor/player uses an interactive element at each time.
Line 73: Line 94:
        
    public func new() super("ExampleElement")    public func new() super("ExampleElement")
-     // Create component and collider to give element a look and feeling +      // Create component and collider to give element a look and feeling 
-     component = ECBehaviorComponent.new(this) +      component = ECBehaviorComponent.new(this) 
-     collider = ECBehaviorCollider.new(this, component) +      collider = ECBehaviorCollider.new(this, component) 
-      +       
-     // Create interaction spot in front of the element. Typically actors need +      // Create interaction spot in front of the element. Typically actors need 
-     // to be rotated by 180 degrees to interact with elements since then the +      // to be rotated by 180 degrees to interact with elements since then the 
-     // actor is looking at the front side of the element. +      // actor is looking at the front side of the element. 
-     //  +      //  
-     // This behavior is named "use". It is not required to use a name but +      // This behavior is named "use". It is not required to use a name but 
-     // it allows to add multiple interaction spots. This can be because the +      // it allows to add multiple interaction spots. This can be because the 
-     // element has more than one possible interaction or different spots the +      // element has more than one possible interaction or different spots the 
-     // same type of interaction can be used. Think of a bench having 3 seats +      // same type of interaction can be used. Think of a bench having 3 seats 
-     // to sit down. This allows three actors to use the bench but with each +      // to sit down. This allows three actors to use the bench but with each 
-     // seat occupied by only one actor +      // seat occupied by only one actor 
-     interactionSpot = ECBehaviorInteractionSpot.new(this, "use"+      interactionSpot = ECBehaviorInteractionSpot.new(this, "use"
-     interactionSpot.getPosition().setVector(Vector.new(0, 0, 0.8)) +      interactionSpot.getPosition().setVector(Vector.new(0, 0, 0.8)) 
-     interactionSpot.getOrientation().setVector(Vector.new(0, 180, 0)) +      interactionSpot.getOrientation().setVector(Vector.new(0, 180, 0)) 
-     interactionSpot.getLookAt().setVector(Vector.new(0, 1.2, 0.2))+      interactionSpot.getLookAt().setVector(Vector.new(0, 1.2, 0.2))
    end    end
 end end
 </code> </code>
 +
 +====== Behavior Factory ======
 +
 +Using element class supporting adding behaviors the behavior can be added like this:
 +<code xml>
 +<?xml version='1.0' encoding='UTF-8'?>
 +<elementClass name='MyClass' class='GenericBehaviorElement'>
 +  <behavior type='ECBehaviorComponent'/>
 +  <behavior type='ECBehaviorCollider'/>
 +  
 +  <behavior type='ECBehaviorInteractionSpot'>
 +    <!-- set element properties. omit property prefix if used inside behavior tag -->
 +    <vector name='.lookAt' x='0' y='0.2' z='0.5'/>
 +  </behavior>
 +  
 +  <!-- for adding multiple behaviors use unique identifiers -->
 +  <behavior type='ECBehaviorInteractionSpot' id='second'/>
 +</elementClass>
 +</code>
 +
 +====== Live Examples ======
 +
 +In the [[https://github.com/LordOfDragons/deexamples|ExampleApp]] you can find a complete example of using this behavior:
 +  * [[https://github.com/LordOfDragons/deexamples/blob/master/exampleApp/data/scripts/InteractionSpotExampleClass.ds|InteractionSpotExampleClass.ds]]: Element class providing an interaction spot the player can use
 +  * [[https://github.com/LordOfDragons/deexamples/blob/master/exampleApp/data/scripts/BehaviorInteractToggle.ds|BehaviorInteractToggle.ds]]: Interaction behavior allowing player to toggle the animated state of an element. This behavior stores the interaction spot the player has to claim.
 +  * [[https://github.com/LordOfDragons/deexamples/blob/master/exampleApp/data/scripts/PlayerActorClass.ds|PlayerActorClass.ds]]: Player actor class. Uses occupier behavior to safely do interactions.
 +  * [[https://github.com/LordOfDragons/deexamples/blob/master/exampleApp/data/scripts/PlayerActionInteractToggle.ds|PlayerActionInteractToggle.ds]]: Player action interacting with BehaviorInteractToggle. Tries to claim the assigned interaction spot and if successful moves to the spot and uses the element. Once finished releases the interaction spot.
 +
dragengine/modules/dragonscript/behavior_interactionspot.1606147735.txt.gz · Last modified: 2020/11/23 16:08 by dragonlord