For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Bean length issue, years later I return to this in hopes to finally nail this down

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
Post Reply
User avatar
Martin Vole
OldUnreal Member
Posts: 23
Joined: Thu Dec 07, 2017 3:45 am

Bean length issue, years later I return to this in hopes to finally nail this down

Post by Martin Vole »

The issue with this little beast is that the beam up close is too long, piercing through the target rather than just hitting them.

Code: Select all

Class TakkraBeamEmitter extends XBeamEmitter
	Transient;
	
#exec TEXTURE IMPORT NAME=FX_takkra_beam_002 FILE=MODELS\FX_takkra_beam_003.pcx GROUP=Effects

var float TraceDistance,MaxTraceDistance;

var Pawn RepOwner;
var vector RepHitLocation;

var float OldError, NewError, StartError, AimError; //used for bot aiming
var rotator AimRotation;
var transient Actor StarterEffect;

simulated function Tick(float Delta)
{
    local vector Start, End;
    local float BeamLengthFactor;

    // Ensure TraceDistance doesn't exceed MaxTraceDistance
    if (TraceDistance < MaxTraceDistance)
        TraceDistance = FMin(TraceDistance + Delta * MaxTraceDistance * 8.f, MaxTraceDistance);

    if (Level.NetMode == NM_Client)
    {
        bHidden = (RepOwner == None);
        if (bHidden)
            return;

        Start = Instigator.Location;
        End = BeamTarget[0].TargetActor.Location;
        SetRotation(rotator(End - Start));
    }

    if (Level.NetMode == NM_DedicatedServer)
    {
        SetLocation(Start);
        return;
    }

    // Calculate the distance between the start and end points
    BeamLengthFactor = VSize(End - Location) / MaxTraceDistance;  // Fraction of MaxTraceDistance

    // Adjust BeamLengthFactor for close distances to prevent the beam from being too long
    if (BeamLengthFactor < 0.2)  // This will adjust the beam when it's up close
    {
        BeamLengthFactor = FMax(BeamLengthFactor, 0.2);  // Ensure the beam doesn't shrink too much
    }

    // Set BoxVelocity based on the adjusted BeamLengthFactor
    BoxVelocity.X.Min = BeamLengthFactor * MaxTraceDistance;  // Simplified scaling
    BoxVelocity.X.Max = BoxVelocity.X.Min * 0.5;  // Keep Max as a smaller fraction for variation
}

defaultproperties
{
	MaxTraceDistance=700.000000
	Segments=1
	MaxParticles=1
	LifetimeRange=(Min=0.300000,Max=0.400000)
	ParticleTextures(0)=Texture'U2Weapons.Effects.FX_takkra_beam_002'
	FadeInTime=0.100000
	FadeOutTime=0.500000
	StartingScale=(Min=6.000000,Max=8.000000)
	BoxVelocity=(X=(Min=0.000000,Max=0.000000))
	bUseRelativeLocation=True
	RemoteRole=ROLE_SimulatedProxy
	bSkipActorReplication=True
	//BeamTargetType=BEAM_Offset
	LifeSpan=0.4
	//BeamTarget(0)=(Offset=(X=0.000000,Y=0.000000,Z=0.000000))
}
User avatar
Martin Vole
OldUnreal Member
Posts: 23
Joined: Thu Dec 07, 2017 3:45 am

Re: Bean length issue, years later I return to this in hopes to finally nail this down

Post by Martin Vole »

Bean? Geez I must have been tired. Anyways, seems there was some code that was disabled that was very important, as in, BeamTarget wasn't even being set, so, working now and looking way better.

Code: Select all

BoxVelocity.X.Min = VSize(BeamTarget[0].TargetActor.Location - Location) - 48; //Why not just do something simple instead?
Post Reply

Return to “UScript Board”