Moving Collison boxes

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

Moving Collison boxes

Post by Collegia Titanica »

I'm very new to this, just started learning like 2 weeks ago, I've nearly completed my unit and it's exactly as I planned, with the exception of hitboxes.

Since it's a rectangular object, I need additional boxes spawned in the front and back. IT works for a non-moving object perfectly, as the invisible squares and the original model size matches the visual quite nicely.

Code: Select all

		TNT1 A 0 A_SpawnItemEx("Collision", 54, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 0 A_SpawnItemEx("Collision", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		TNT1 A 0 A_SpawnItemEx("Collision", -54, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
However, I need the same but on a moving target. I've briefly skimmed over the forum, and have seen this response which is kind of unclear to me :
"Spawning something every frame? What is this, the ice age? :P The collider would be spawned only once, storing its "spawner" in a pointer. ZScript lets you do this stuff conveniently. Yeah, sure the actor count would go up, but you don't have to spawn something every frame is my point."
So how do I go about this ? Can anyone guide me or even write something which I can add to my actor ?

Another question: How can I make these collision boxes be ... well ... sensitive ? Like damaging them damages my actor ( because if the projectiles hit from behind or front, they crash into the coll box and the actor is undamaged)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Moving Collison boxes

Post by Matt »

I should probably put up a ZScript tutorial for this, but in the meantime I think one can piece together an answer (and I say a better answer than what's been posted on these forums so far) by getting familiar with the following:

pointers
Tick()
Vec3Angle()
SetOrigin()
DamageMObj()
CanCollideWith()
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Moving Collison boxes

Post by Matt »

Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

Re: Moving Collison boxes

Post by Collegia Titanica »

@Matt

Thank you mortal. I will resume my work when I can, in the meantime, where is the best place to post about my small project/model ? It's like 85% done, just need collision and some texture change. A video demonstration will be made, you're all gonna love it.
Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

Re: Moving Collison boxes

Post by Collegia Titanica »

Matt wrote:Hope this helps!
OK so I've been trying and failing with this. Perhaps this isn't a zscript format problem, as my actor is written in DECORATE, or I have no idea what I'm doing. I've created a ZScript format text file and tested the code.I tweaked the parameters, and it blocks the damage as intended. It would be better if this code was not relative to the mouselook, like whether you look up or down, the hitbox is always in front of you.

All this is for a moving vehicle btw.

If I change the ExampleShieldGiver to an actor and pickoff to a spawn, and then I try to summon the actor ...GZDOOM freezes. I just tried to

Code: Select all

TNT1 A 0 A_GiveToTarget("ExampleShieldGiver")
And
TNT1 A 0	A_SpawnItemEx("ExampleShield", 0, 0, 0)
in the spawn state of my decorate actor but it did nothing.

Firstly I don't know how to connect the 2 entities.
Secondly I also need collision on this, but it's very messed up, I've tried with +SOLID and the results were horrible. All this is so confusing, I just wanted a quick fix ... 2 invisible boxes that end where the moving model ends so it can collide properly with everything and can take damage :((
User avatar
TheZombie
Posts: 53
Joined: Tue Mar 28, 2017 8:49 pm
Contact:

Re: Moving Collison boxes

Post by TheZombie »

Open up the latest build of BD and check out the scripts for the Tanks, helicopters and Mechs.
Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

Re: Moving Collison boxes

Post by Collegia Titanica »

That's exactly what I've done/am doing, my unit is ready, however it's a rectangle, the BD examples are box shaped. I guess I'll keep trying
Post Reply

Return to “Scripting”