Forum Discussion
Ben.SH
1 year agoCommunity 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.
Exo_Guid
1 year agoMHCP Partner
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);