Forum Discussion

starpool108's avatar
6 months ago

Assigning throw as an icon for mobile users

The die I have in my world is grabbable but the only way a player can roll is to "drop" it with the automatically assigned icon (it's in the lower left). I don't believe I am assigning throw correctly as a primary icon since nothing happens when I test it. Is there another step to this? 

4 Replies

  • Ben.SH's avatar
    Ben.SH
    Community Manager

    Have you taken a look at this Throwing documentation to ensure you have the grabbable object properties configured properly? There is also an example code as well in that article.

    • starpool108's avatar
      starpool108
      Member

      I will continue to try and figure this out. I haven't encountered "enable throwing controls" when I attempt this, but have seen it before on shared assets. I have yet to use typescript. 

       

      • Exo_Guid's avatar
        Exo_Guid
        Member

        If you hold the default drop button until the green ring completes you'll throw the object held.  I'm working on this as well and will post when I get it figured.

    • Exo_Guid's avatar
      Exo_Guid
      Member

      Hi Ben, I've tried to follow the Throwing Documentation and have had the Desktop Editor crash multiple times.  Typically after multiple grabs of the same object (DiceWhite_geom from public assets).  It does manage to throw once.  Throwing controls is enabled.  I've filled a bug report and included the Windows Event application error.  Here's the code I'm using stripped down after multiple attempts:

      import { Component, CodeBlockEvents, PlayerDeviceType, Player, Handedness } from 'horizon/core';
      
      class DiceThrow extends Component<typeof DiceThrow> {
        static propsDefinition = {
      
        };
      
      
      
      
        start() {
      
      this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnIndexTriggerDown, (player: Player)=> {
        // Ignore on VR devices
        if (player.deviceType.get() == PlayerDeviceType.VR) {
          return;
        }
      
        // Setup the throw options
        let opt = {
          speed: 25,
          pitch: 30
        }
      
        // Calling Throw Held Item
        player.throwHeldItem(opt);
      
      }
        )}
      }
      
      Component.register(DiceThrow);