YesNoOk
avatar

Make a projectile ignore camera (Read 1217 times)

Started by DR119, February 02, 2018, 04:29:39 pm
Share this topic:
Make a projectile ignore camera
#1  February 02, 2018, 04:29:39 pm
  • avatar
  • **
Is it possible to make a projectile ignore the camera like an explod with space = screen?
Last Edit: February 03, 2018, 11:51:01 am by DR119
Re: Make a projectile ignore camera
#2  February 03, 2018, 01:43:28 pm
  • ******
  • Loyal to the Game
  • I'M SHADYYYYYYYYYY
    • USA
    • http://jesuszilla.trinitymugen.net/
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.
Re: Make a projectile ignore camera
#3  February 05, 2018, 02:13:16 am
  • avatar
  • **
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?
Re: Make a projectile ignore camera
#4  February 06, 2018, 02:57:04 am
  • *****
  • Shame on you!
    • USA
Not at all. Well kinda. You just have a float value where it should be a whole number.
Use
y=Floor(var(2))
vVv Wheat Stage Released vVv