R
robproctor83
Guest
Okay, this is a long outstanding issue that I have had in my project that I am trying to fix, but it seems like no matter what I try it has some other issue. I attached an image to help explain, but my problem is that my ammo can get stuck in the wall if the player is too close. The ammo start extended out from the player, and so I need some way to pull the ammo out of the wall.
I have tried a number of things, but essentially what I want is for the ammo to instantly teleport to the right location. The closest I have gotten is the code below, but the problem is it only works with walls to the left/right and not up/down because it's got the x/y separated and moves x first, so if it's a y wall it will try moving it x first and that isn't what I want.
I think, what I need is to do something like check and see if _collide is y positioned or x positioned and then run one of the two chunks.. But, the problem there would be walls that are diagnal, I don't think it would work there.
Also, just to note, I have tried other things like reversing the direction towards the player, or move_outside_* over time instead of instantly, it's like no matter what I do there is some other issue.
I have tried a number of things, but essentially what I want is for the ammo to instantly teleport to the right location. The closest I have gotten is the code below, but the problem is it only works with walls to the left/right and not up/down because it's got the x/y separated and moves x first, so if it's a y wall it will try moving it x first and that isn't what I want.
Code:
var _collide = instance_place(x, y, obj_Solid);
if(move_x_sp != 0){
var collide = instance_place(x+move_x_sp,y,obj_Solid);
if(instance_exists(collide) && collide.solid){
if(_collide){
var _pdir = point_direction( 0, 0, sign(owner.x-x), 0);
move_outside_solid(_pdir, -1);
}
move_x_sp = 0;
}
x += move_x_sp*scr_delta(time.Global);
}
else{
move_x_sp = cos(move_direction) * move_speed;
}
if(move_y_sp != 0){
var collide = instance_place(x,y+move_y_sp,obj_Solid);
if(instance_exists(collide) && collide.solid){
if(_collide){
var _pdir = point_direction( 0, 0, 0, sign(owner.y-y));
move_outside_solid(_pdir, -1);
}
move_y_sp = 0;
}
y += move_y_sp*scr_delta(time.Global);
}
else{
move_y_sp = sin(move_direction) * move_speed;
}
Also, just to note, I have tried other things like reversing the direction towards the player, or move_outside_* over time instead of instantly, it's like no matter what I do there is some other issue.
Attachments
-
10.4 KB Views: 18