Code: Select all
public void OnUpdate( TriggerArgs Btn )
{
IPlayer caller = (IPlayer)Btn.Sender;
IUser pusher = caller.GetUser();
IPlayer playr = pusher.GetPlayer();
Vector2 worldPos = playr.GetWorldPosition() + new Vector2 (5,5);
int playr_dir = playr.FacingDirection;
ProjectileItem rocket = ProjectileItem.UZI;
if (playr_dir == 1)
{
IObject rndPositive_Obj = Game.GetSingleObjectByCustomId("rndObj_pos");
// i have 2 objects in my map that allow me to make the bullet either go left or right, the object in this case is rndObj_pos ... this object is in the right side of the map making the bullet go right
Vector2 positiveObj_pstn = rndPositive_Obj.GetWorldPosition();
Game.SpawnProjectile(rocket, worldPos, positiveObj_pstn);
Game.ShowPopupMessage(positiveObj_pstn.ToString());
} else if (playr_dir == -1)
{
IObject rndNegative_Obj = Game.GetSingleObjectByCustomId("rndObj_neg");
// i have 2 objects in my map that allow me to make the bullet either go left or right, the object in this case is rndObj_neg ... this object is in the leftside of the map making the bullet goes left
Vector2 negativeObj_pstn = rndNegative_Obj.GetWorldPosition();
Game.SpawnProjectile(rocket, worldPos, negativeObj_pstn);
Game.ShowPopupMessage(negativeObj_pstn.ToString());
}
}
Code: Select all
Script Error
Error in method 'Btn_Press(TriggerArgs)' in map script. See the exception for more details:
--- Exception ---
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at SFDScript.GameScript.Btn_Press(TriggerArgs Btn)
Thanks.

