Page 2 of 2
Re: Shoot Bullets to player coordinate
Posted: Thu Sep 19, 2019 8:31 am
by Emral
'kay so... What I THINK is happening is that your bullet isn't configured to move opposite to its direction value somehow? Try to add the following bit of code to spawnAtDirection:
if directionVector.x ~= 0 then
n.direction = math.sign(directionVector.x)
end
You need to put this section before setting speedX, because setting direction afterwards does some weird stuff to speed I don't quite understand.
If that trick doesn't work... then I'm not sure.
Re: Shoot Bullets to player coordinate
Posted: Tue Sep 24, 2019 6:01 am
by ItsRealGaming[R]
Idk what about the frame... But let's move on something else... How would I make a custom block but it's a slope... Without replace a available one... Also, how would I make a one-way block?
P/s: How do I check for bumped block too?
Re: Shoot Bullets to player coordinate
Posted: Tue Sep 24, 2019 6:17 am
by Emral
Bumping routes through the onBlockHit function
function onBlockHit(eventObj, hitBlockObject, fromUpperSide, playerOrNil)
...
end
Use like onNPCHarm and onNPCKill.
For the block property settings, lua is required at the moment. You can manipulate them with Block.config
Examples:
Block.config[751].bumpable = true
Block.config[752].semisolid = true
Block.config[753].floorslope = 1 (or -1, depending on direction)
There's also ceilingslope (works same as floorslope), passthrough (nonsolid), pswitchable, sizeable, and lava (all booleans), as well as frames (int) and the 5 darkness related fields that also exist for NPCs and BGOs (lightoffsetx, lightoffsety, lightradius, lightbrightness, lightcolor)
Re: Shoot Bullets to player coordinate
Posted: Tue Sep 24, 2019 6:41 am
by ItsRealGaming[R]
Awesome... So does this work with 32x64 slope? Or I have to make 2 different pieces? Also can I do the uppersolid or bottomsolid or leftsolid... lol I'm dumb... Or should I use NPC...?
Re: Shoot Bullets to player coordinate
Posted: Tue Sep 24, 2019 6:47 am
by Emral
Bottomsolid and sidesolid are not supported by SMBX. You gotta do some weird hacks to get those working, and even then it's hard to make them work for players AND npcs.
Blocks resize automatically based on their image size. The slope flags just define the orientation of the collision triangle (which is then stretched to fit the image size).
Re: Shoot Bullets to player coordinate
Posted: Tue Sep 24, 2019 6:50 am
by ItsRealGaming[R]
Lol that's no big deal... I believe lua can implement pretty much thing... In the future, it will be possible :3. Thank for helping
Re: Shoot Bullets to player coordinate
Posted: Tue Oct 01, 2019 8:50 am
by ItsRealGaming[R]
How do I check for block collision? I use collision up/down/left/right but my custom npc stuck at ceiling slope (btw my custom is no gravity and speed = 0 with my old spawnAtDirection function)...
Re: Shoot Bullets to player coordinate
Posted: Tue Oct 01, 2019 9:04 am
by Emral
ItsRealGaming[R] wrote: ↑Tue Oct 01, 2019 8:50 am
How do I check for block collision? I use collision up/down/left/right but my custom npc stuck at ceiling slope (btw my custom is no gravity and speed = 0 with my old spawnAtDirection function)...
What are you trying to do? If you're trying to reflect it, look at rebound.lua in the scripts/npcs folder.That file is used by diagonal podoboos and boo snakes. For proper reflections you have to work with raycasts. If you're just trying to kill it or whatnot, the collidesBlockBottom/Top/Left/Right flags should work as long as the NPC has block collision enabled.
Re: Shoot Bullets to player coordinate
Posted: Thu Oct 03, 2019 5:59 am
by ItsRealGaming[R]
ok nvm... This is solved... But how can I make a custom powerup without replace or fix the current power...?
Re: Shoot Bullets to player coordinate
Posted: Thu Oct 03, 2019 6:35 am
by Emral
You must replace an existing powerup at the moment. If we had the ability to add more yet, there would be some in basegame.
Re: Shoot Bullets to player coordinate
Posted: Fri Dec 24, 2021 4:19 am
by kirbyhasn
i think this might be good for tank levels
like player control a tank and shoot using mouse pointer to aim