Skip to content

Commit ce1dc02

Browse files
committed
rotors can turn in the correct direction when hit
1 parent e5c0dc1 commit ce1dc02

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

objects/obj_3d_spell_rotor/Create_0.gml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ self.state = new SnowState("still", false)
1010
leave: function() {
1111
self.spell_response = undefined;
1212
},
13-
onspell: function() {
14-
self.target_direction = self.rotor_direction + 90;
13+
onspell: function(hit_info) {
14+
var vector_to_hit = hit_info.point.Sub(hit_info.shape.position);
15+
var direction_to_hit = point_direction(0, 0, vector_to_hit.x, vector_to_hit.z);
16+
var vector_to_rotor = hit_info.shape.position.Sub(new Vector3(self.x, self.y, self.z));
17+
var direction_to_rotor = point_direction(0, 0, vector_to_rotor.x, vector_to_rotor.z);
18+
19+
if (angle_difference(direction_to_hit, direction_to_rotor) > 0) {
20+
self.target_direction = self.rotor_direction + 90;
21+
} else {
22+
self.target_direction = self.rotor_direction - 90;
23+
}
1524
self.state.change("turning");
1625
}
1726
})
@@ -28,8 +37,8 @@ self.state = new SnowState("still", false)
2837
}
2938
});
3039

31-
self.OnSpellHit = function(spell) {
40+
self.OnSpellHit = function(spell, hit_info) {
3241
if (spell.object_index != self.spell_response) return;
3342

34-
self.state.onspell();
43+
self.state.onspell(hit_info);
3544
};

objects/obj_game/Create_0.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ block.SetMesh(self.meshes.block);
9595
block.UpdateCollisionPositions();
9696

9797
var rotor_1 = instance_create_depth(100 - 128, 0, -450, obj_3d_spell_rotor);
98-
rotor_1.SetMesh(self.meshes.rotor_1);
98+
rotor_1.SetMesh(self.meshes.rotor_3);
9999
rotor_1.UpdateCollisionPositions();
100100

101101
enum ECollisionMasks {

objects/obj_player/Create_0.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ self.IsGrounded = function() {
199199
};
200200

201201
self.DrawSpellSymbol = function() {
202-
if (self.spell_symbol != undefined) {
202+
if (self.spell_symbol != undefined && self.spell_symbol.obj.spell_response != undefined) {
203203
var info = self.spell_symbol;
204-
204+
205205
static cache = { };
206206

207207
if (cache[$ string(info.obj.spell_response)] == undefined) {

objects/obj_spell/Step_0.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ self.caster.cobject.mask = caster_mask;
1515

1616
if (raycast_result) {
1717
if (raycast_result.distance <= self.velocity.Magnitude() * DT) {
18-
raycast_result.shape.object.reference.OnSpellHit(self.id);
18+
raycast_result.shape.object.reference.OnSpellHit(self.id, raycast_result);
1919
instance_destroy();
2020
return;
2121
}

0 commit comments

Comments
 (0)