The Mugen Fighters Guild

Help => M.U.G.E.N Development Help => Topic started by: DR119 on February 02, 2018, 04:29:39 pm

Title: Make a projectile ignore camera
Post by: DR119 on February 02, 2018, 04:29:39 pm
Is it possible to make a projectile ignore the camera like an explod with space = screen?
Title: Re: Make a projectile ignore camera
Post by: Jesuszilla on February 03, 2018, 01:43:28 pm
As in, have the projectile at the exact same screen coordinates no matter where the camera is? Don't believe you can do that with a normal projectile (which you really shouldn't be using anyway), but you can use a helper.

You'd need to constantly check/set the Pos of the Helper and set it according to GameWidth and GameHeight. I think you'd also need to use ScreenPos to do the necessary math.

The X portion should be easy since the value is always relative to the center of the screen; it's the Y pos that's going to be a bit trickier since it's always relative to the stage floor and we have no StageHeight trigger.


However, if we get the ScreenPos at Time = 0 (say, in a helper) while the Y Pos is 0, we can calculate the height in pixels from the bottom of the screen, effectively giving us the StageHeight we need:
Code:
[State x, VarSet]
type = VarSet
trigger1 = Time = 0
var(x) = GameHeight - ScreenPos Y

Using var(x) (where x is whatever variable number you want it to be), you should be able to do a PosSet for Y anywhere on the screen using a combination of Pos Y and ScreenPos Y.
Title: Re: Make a projectile ignore camera
Post by: DR119 on February 05, 2018, 02:13:16 am
As in, have the projectile at the exact same screen coordinates no matter where the camera is? Don't believe you can do that with a normal projectile (which you really shouldn't be using anyway), but you can use a helper.

You'd need to constantly check/set the Pos of the Helper and set it according to GameWidth and GameHeight. I think you'd also need to use ScreenPos to do the necessary math.

The X portion should be easy since the value is always relative to the center of the screen; it's the Y pos that's going to be a bit trickier since it's always relative to the stage floor and we have no StageHeight trigger.


However, if we get the ScreenPos at Time = 0 (say, in a helper) while the Y Pos is 0, we can calculate the height in pixels from the bottom of the screen, effectively giving us the StageHeight we need:
Code:
[State x, VarSet]
type = VarSet
trigger1 = Time = 0
var(x) = GameHeight - ScreenPos Y

Using var(x) (where x is whatever variable number you want it to be), you should be able to do a PosSet for Y anywhere on the screen using a combination of Pos Y and ScreenPos Y.


But if I use the var as the y value in the PosSet sctrl, an error message appears : "Waring: expression truncated to integer" and the projectiles are still affected by the camera movement.
Code:
[State 305, VarSet]
type = VarSet
trigger1 = Time = 0
trigger1 = ishelper
var(2) = GameHeight - ScreenPos Y
[state 305]
type=PosSet
trigger1=1
y=var(2)
Am I doing something wrong?
Title: Re: Make a projectile ignore camera
Post by: Odb718 on February 06, 2018, 02:57:04 am
Not at all. Well kinda. You just have a float value where it should be a whole number.
Use
y=Floor(var(2))