Need help with CollisionZone

Discussions about Coding and Scripting
Post Reply
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Need help with CollisionZone

Post by PrinceOfFunky »

I made this "one-line" code to make a zone acting like a wall, blocking actors.
Zb6TJnOvBZU
This is the code:

Code: Select all

class CollisionZone extends ZoneInfo;

event ActorEntered(Actor other) {
	other.HitWall(Normal(other.Location - Location), self);
}

defaultproperties
{
	bCollideActors=true
	bCollideWorld=true
	bBlockActors=true
	bBlockPlayers=true
}
As you can see from the video, projectiles act like it is a wall indeed, but few of them don't. Plus the player can still pass through it.
I tried putting "other.SetLocation(other.OldLocation)", but that completly blocks the player, like even in mid air.
Other things I tried are: - Calling other.Bump(self) - and other.Touch(self) - HitActor = Spawn(a blockall with bStatic set to False), still nothing.
Is what I'm trying to achieve even possible?
"Your stuff is known to be buggy and unfinished/not properly tested"
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Need help with CollisionZone

Post by JackGriffin »

I ran into the same issues when working on the frying pan. I wanted it to divert incoming projectiles back at the person shooting them. Ended up just giving up because projectile code is an absolute miasma of simulated, non-simulated, replicated, non-replicated voodoo. You will not be able to just do a simple "fix".

For the bonus round, just wait till you try this online. It's even worse.
So long, and thanks for all the fish
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Need help with CollisionZone

Post by PrinceOfFunky »

JackGriffin wrote:I ran into the same issues when working on the frying pan. I wanted it to divert incoming projectiles back at the person shooting them. Ended up just giving up because projectile code is an absolute miasma of simulated, non-simulated, replicated, non-replicated voodoo. You will not be able to just do a simple "fix".

For the bonus round, just wait till you try this online. It's even worse.
I think invertono the velocity would have been enough.

EDIT: I tried replacing the one-line code into this:

Code: Select all

Spawn(class'Blocker',,,other.Location).LifeSpan = 10;
But whenever something hits the zone the game crashes giving this error:

Code: Select all

Critical: DMMutator DM-CollisionZone.DMMutator0 (Function Botpack.DMMutator.CheckReplacement:0000) Infinite script recursion (250 calls) detected
I thought CheckReplacement was called only at the beginning of the game.
"Your stuff is known to be buggy and unfinished/not properly tested"
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Need help with CollisionZone

Post by JackGriffin »

Not gonna work. A ton of projectile is simulated. The server may reorient or destroy the projectile but the client will still see it travel along the original path until it updates or times out. You can see this easily by scripting a zone that adds velocity to projectiles then shooting through it while online. You'll see different projectiles will do wildly different things depending on their settings.

You could create your own projectile class that will respond correctly to what you are doing but that won't help with default ones.
So long, and thanks for all the fish
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Need help with CollisionZone

Post by Barbie »

PrinceOfFunky wrote:I thought CheckReplacement was called only at the beginning of the game.
GameInfo.IsRelevant(), BaseMutator.IsRelevant(), $AllMutators.AlwaysRelevant() is always called for Actors entering the Level. Depending on its result $AllMutators.CheckReplacement() is called, too. See Wiki: Chain_Of_Events_When_Spawning_Actors for details.

Code: Select all

class CollisionZone extends ZoneInfo;
What is the aim of this? I'd realize that with a zone and invisible brush.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Need help with CollisionZone

Post by PrinceOfFunky »

Barbie wrote:

Code: Select all

class CollisionZone extends ZoneInfo;
What is the aim of this? I'd realize that with a zone and invisible brush.
True but:
- 2 brushes are needed.
- The invisible brush cannot touch any surface.
If it is a zone, some stuff you could do is:
- Collision can eventually be toggled.
- Possibility to customize it, like letting only one team to pass through.
"Your stuff is known to be buggy and unfinished/not properly tested"
Post Reply