mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
Firing works
This commit is contained in:
parent
aed5629eca
commit
4bf1c36fd6
2 changed files with 40 additions and 5 deletions
|
@ -773,7 +773,7 @@ function MyController(hand) {
|
|||
this.setState(STATE_CONTINUE_NEAR_GRABBING);
|
||||
} else {
|
||||
// equipping
|
||||
Entities.callEntityMethod(this.grabbedEntity, "equip", [JSON.stringify(this.hand)]);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startEquip", [JSON.stringify(this.hand)]);
|
||||
this.setState(STATE_CONTINUE_EQUIP_BD);
|
||||
}
|
||||
|
||||
|
@ -808,7 +808,7 @@ function MyController(hand) {
|
|||
}
|
||||
if (this.state == STATE_CONTINUE_NEAR_GRABBING && this.bumperSqueezed()) {
|
||||
this.setState(STATE_CONTINUE_EQUIP_BD);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "equip", [JSON.stringify(this.hand)]);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startEquip", [JSON.stringify(this.hand)]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
|
||||
(function() {
|
||||
|
||||
var scriptURL = Script.resolvePath('pistol.js');
|
||||
var _this;
|
||||
Pistol = function() {
|
||||
|
@ -22,19 +23,53 @@
|
|||
|
||||
Pistol.prototype = {
|
||||
|
||||
equip: function() {
|
||||
startEquip: function(id, params) {
|
||||
print("HAND ", params[0]);
|
||||
this.equipped = true;
|
||||
print("EQUIP")
|
||||
this.hand = JSON.parse(params[0]);
|
||||
|
||||
},
|
||||
unequip: function() {
|
||||
this.equipped = true;
|
||||
print("UNEQUIP")
|
||||
this.equipped = false;
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
print("INIT CONTROLLER MAPIING")
|
||||
this.initControllerMapping();
|
||||
},
|
||||
|
||||
triggerPress: function(hand, value) {
|
||||
print("TRIGGER PRESS");
|
||||
if (this.hand === hand && value === 1) {
|
||||
//We are pulling trigger on the hand we have the gun in, so fire
|
||||
this.fire();
|
||||
}
|
||||
},
|
||||
|
||||
fire: function() {
|
||||
print("FIRE!");
|
||||
},
|
||||
|
||||
initControllerMapping: function() {
|
||||
this.mapping = Controller.newMapping();
|
||||
this.mapping.from(Controller.Standard.LT).hysteresis(0.0, 0.5).to(function(value) {
|
||||
_this.triggerPress(0, value);
|
||||
});
|
||||
|
||||
|
||||
this.mapping.from(Controller.Standard.RT).hysteresis(0.0, 0.5).to(function(value) {
|
||||
_this.triggerPress(1, value);
|
||||
});
|
||||
this.mapping.enable();
|
||||
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
this.mapping.disable();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
|
|
Loading…
Reference in a new issue