UE1 - UT Vectors & moving effects....

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Well here is the scenario....

I decided to extend my blood drop effect, with a version that would
bounce around and slide off across the floor.

Ideally the drops would stick to a wall when they hit it, and then drip down.
Would randomize the rate of dripping once I got that too work.

Figured out a way via trial and error to get things almost working the way
they should for it. Took me a while as almost everything I tried had
the opposite effect of what I was wanting. Of course if I reverse it at
that point, nothing happened....

Only problems with current version is that the drops will slide up ramps
or inclined surfaces, which don't look quite right... And when they
stick to the wall, they stop instead of sliding down.

Had a number of versions where the drops would climb up the walls and
stick to the ceiling until their timers ran out, but cant get it to do the
opposite.

Also the drop seem to jump at the wall and stick to it at about the current
bounce height when they get real close. Like they are magnets and
the wall is steel.

It would be better if they stopped or headed downhill, if heading downhill
was available at that location.

I searched the Wiki's and the web for info on vectors and projectiles, but
found very little that helped me with this.

Server here is running the current version of this: 69.210.212.204:7877

Code below probably has some problems, but it is the closest I have gotten
so far to what I want. Most likely some unneeded stuff in it I put in
during attempts to get the drops from climbing to the roof.....

Note: SpurtLevel2 is a config variable. Range has been 20..110 in testing.

Code:
//=============================================================================
// utb_BloodDrop2.
//=============================================================================
class UTB_BloodDrop2 extends UTB_BloodDrop;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity.x += (FRand()*class'MB5.MB'.default.SpurtLevel2) + 2;
		Velocity.y += (FRand()*class'MB5.MB'.default.SpurtLevel2) + (class'MB5.MB'.default.SpurtLevel2 / 2);
		Velocity.z += (FRand()*class'MB5.MB'.default.SpurtLevel2) + (class'MB5.MB'.default.SpurtLevel2);
	}
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity.x -= (FRand()*(10) + 2);
		Velocity.y -= (FRand()*(10) + 2);
		Velocity.z += (FRand()*(class'MB5.MB'.default.SpurtLevel2) * 2);
	}
}

simulated function Landed( vector HitNormal )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity.x = (Velocity.x * -1);
		Velocity.y = (Velocity.y * -1);
		Velocity.z = (Velocity.z * -1);
	}
}


defaultproperties
{
}

Any feedback would be good. Links to a Wiki page or tutorial I failed to find
that might shed some light, names of some other Vectors or variables other
than Velocity that might effect this.

If some quick, easy fix to the above pops into your head, feel free to post
that also.... :D

Thanks for looking.
 

meowcat

take a chance
Jun 7, 2001
803
3
18
It sounds to me like you want the drop to go ahead and slide down walls after it hits (no bouncing per se)). To do this obviously have to set their velocity in the direction of 'perpendicular down' to the wall. My (untested) recommendation follows using the crossproduct (see comments in code about inverting....):
Code:
simulated function HitWall( vector HitNormal, actor Wall )
{
	local vector vDown, vHoriz;
        if (Level.NetMode != NM_DedicatedServer)
	{
		vHoriz = HitNormal cross vect(0,0,1); // create the vector perfectly horizontal to the wall
                vDown = vHoriz cross HitNormal; // this creates the vector aiming down and 'along' the surface, but note that you may have to update later if it slides off an edge.
                vDown *= -1; // this may not be neccessary, it depends on which order you perform the crossproduct, e.g.:  vHoriz cross HitNormal OR HitNormal cross vHoriz
                
                Velocity = vDown * (2 + 10*FRand());
                // OR, in order to ensure that it always move down even if there in no edge, just set the velocity as follows (may want to overwrite some other functions
                Velocity = vect(0,0,-1) * (2 + 10*FRand()); // only set velocity in the -z direction
               
                //Velocity.x -= (FRand()*(10) + 2);
		//Velocity.y -= (FRand()*(10) + 2);
		//Velocity.z += (FRand()*(class'MB5.MB'.default.SpurtLevel2) * 2);
	}
}

Sorry I don't have pictures,a s those would help better demonstrate the cross product application...
 
Last edited:

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Thanks a lot for that.

I think if I apply that to the class the code I posted is extending, I will have
both effects doing exactly what they should. (I hope...)

UTB_BloodDrop spawns drops that stick where they land, then expire after
a bit.

UTB_BloodDrop2 extends that and animates them across the floor a bit.
Think I got most of the issues I was having with it last night fixed now.
Cleaned out the unneeded crap also. I was tired when I started this
thread....

Just got done 5 minutes ago with a rewrite of that. About to toss current
test version of my MoreBlood mutator on the servers now.

Here is what it looks like now:

Code:
class UTB_BloodDrop2 extends UTB_BloodDrop;

var int r;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	if (Level.NetMode != NM_DedicatedServer)
	{
		r = (FRand()*class'MB6.MB'.default.SpurtLevel2) + 60;
	}
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	if (Level.NetMode != NM_DedicatedServer)
	{

		Velocity = (Vector(Rotation) + VRand()) * (class'MB6.MB'.default.SpurtLevel2 * FRand() + class'MB6.MB'.default.SpurtLevel);
		Velocity.z += r;
		r -= Rand(9) + 1;
	}
}

defaultproperties
{
}
 

meowcat

take a chance
Jun 7, 2001
803
3
18
You need to set the value of R before adding it to Velocity.z if you want it to affect the value of z. Also, be warned that the use of VRand() above may give the drop a velocity direction away from the wall altogether.
 

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Solved, Almost....

You need to set the value of R before adding it to Velocity.z if you want it to affect the value of z.

R gets initialized in PostBeginPlay(). Calculation on r in HitWall is used to
slow down the drop a bit on each bounce until it stops.

Also, be warned that the use of VRand() above may give the drop a velocity direction away from the wall altogether.

Exactly correct. Latest re-write of this no longer has that issue.
Your suggestions were very helpful in getting me and the blood drops
pointed in the right direction, although the only bit I actually used
was the *= -1;

See below:

Code:
class UTB_BloodDrop2 extends UTB_BloodDrop;

var int r, g;

simulated function PostBeginPlay()
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity = (Vector(Rotation) + VRand()) * (class'MB6.MB'.default.SpurtLevel2 * FRand() + class'MB6.MB'.default.SpurtLevel);
		r = (FRand()*class'MB6.MB'.default.SpurtLevel) + 5;
		Velocity.x += r;
		Velocity.z += r;
		g = Rand(5) + 1;
		SpawnDrop();
	}
	Super.PostBeginPlay();
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity.z += r;
		Velocity.z *= -1;
		r = r + g;
	}
}

simulated function Landed( vector HitNormal )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		Velocity.z -= r;
	}
}

defaultproperties
{
     AmbientGlow=90
}

That works pretty much perfect. Drops never seem to slide up anything
anymore. Stick to walls and then slide down at a random rate.
Start off bouncing in a random direction and then continue in a mostly
straight line, bouncing lower and slowing down on each bounce.
Either bounce down or stick where they landed on inclines.

Only issue so far showed up when I put it on the servers.
The effect spawns when it should. Every single part of it seems ok except
for one thing. Instead of moving across the floor, the drops bounce for a
while at the spot where they landed.

It is as if every part of the above class is working online except the one
line: Velocity.x += r;

This has me somewhat baffled, and also gave me an idea for yet another
variation of the effect my mutator could use in addition to all the others.

Any idea why horizontal travel would work online, but vertical movement
vanishes ?
 

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Note: HitWall is named wrong. It shoud be HitWallorFloor.....

Didnt find function HitFloor noplace.
 

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Gonna try moving the Velocity.x += r; line down into the HitWall function, but only
have it execute once...... That may do it.
 

MrLoathsome

New Member
Apr 1, 2010
100
0
0
Got all that working now. Here is the final version:

Code:
//=============================================================================
// utb_BloodDrop2.   Bouncy moving drops
//=============================================================================
class UTB_BloodDrop2 extends Blood2;

var int r, g, d;
var float prevloc;

simulated function PostBeginPlay()
{
	r = (FRand()*class'MB8.MB'.default.SpurtLevel2) + (class'MB8.MB'.default.MaxBleeders);
	g = Rand(3) + 1;
	d = Rand(8) + 1;
	Velocity.x += (Rand(class'MB8.MB'.default.MaxBleeders) + g) * 10;
	Velocity.z += (Rand(class'MB8.MB'.default.MaxBleeders) + d) * 5;
	Velocity.y += d * g;
	Texture = MultiSkins[Rand(8)];
	Drawscale = (FRand()*0.30) + 0.0125;
	LifeSpan = (class'MB8.MB'.default.BleedTime / 4) + Rand(4);
	if (Level.NetMode != NM_DedicatedServer)
	{
		SpawnDrop();
	}
	Super.PostBeginPlay();
}

simulated function SpawnDrop()
{
	local Actor A;

	A = spawn(class'UT_BloodDrop');
	A.RemoteRole = ROLE_SimulatedProxy;
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
	  if ((prevloc != Self.Location.z) && (Velocity.z > -255.0))
		  {
			Velocity.z += r;
			r = r + g;
			Velocity.z *= -1;
		  }
		  else
		  {
			Velocity.z += r+5;
			r = r + d;
			d = d + g;
			if (Velocity.z > 0)
				Velocity.z *= -1;
		  }
	prevloc = Self.Location.z;
	}
}

simulated function Landed( vector HitNormal )
{
	if (Level.NetMode != NM_DedicatedServer)
	{
	  if ((prevloc != Self.Location.z) && (Velocity.z > -255.0))
	  {
		Velocity.z -= r;
	  }
	}
}

defaultproperties
{
     bHighDetail=True
     Physics=PHYS_Falling
     bStatic=False
     LifeSpan=3.500000
     DrawType=DT_Sprite
     Style=STY_Masked
     Texture=Texture'Botpack.Blood.BD3'
     DrawScale=0.250000
     AmbientGlow=180
     MultiSkins(0)=Texture'Botpack.Blood.BD3'
     MultiSkins(1)=Texture'Botpack.Blood.BD4'
     MultiSkins(2)=Texture'Botpack.Blood.BD6'
     MultiSkins(3)=Texture'Botpack.Blood.BD9'
     MultiSkins(4)=Texture'Botpack.Blood.BD10'
     MultiSkins(5)=Texture'Botpack.Blood.BD3'
     MultiSkins(6)=Texture'Botpack.Blood.BD4'
     MultiSkins(7)=Texture'Botpack.Blood.BD6'
     bCollideWorld=True
     bBounce=True
     NetPriority=2.000000
}

The drops are a bit on the superball/bouncy side with this, but that way
more of them stick to the walls and drip down. This is only one of a
number of effects in the mutator, so they blend in well I think.