my decal issue

Discussions about Coding and Scripting
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

my decal issue

Post by >@tack!< »

Hey guys, i was trying to fix my shockrifle for my BTclan for online. i fixed most things, only 2 more things to fix, and one if them is involving a decal.

It only spawns if i shoot it at walls facing 1 particular way,

red = decal
Image

i spawn an actor with location: hitlocation + hitnormal and rotation: rotator(HitNormal)
and that actor spawns several FX including the decal, everything except the decal is spawned ok
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: my decal issue

Post by Rakiayn »

post the code so we can see whats wrong
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: my decal issue

Post by >@tack!< »

Code: Select all

class VRN_SuperShockRifle expands SuperShockRifle;
...
...
...
function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
...
...
...
Spawn(class'VRN_BTSSRExplosionSet',,,HitLocation+HitNormal,rotator(HitNormal));
...
...
...

Code: Select all

class VRN_BTSSRExplosionSet expands Effects;



simulated function postbeginplay()
{
local effects s,q;

	s =	Spawn(class'SmallSpark2');
	s.DrawScale *=3.5;
	s.RemoteRole = ROLE_None;
	q = Spawn(Class'SmallSpark');
	s.RemoteRole = Role_None;
	Spawn(class'EnergyImpact',);
	
}
the energyimpact is the subject
JackGriffin
Godlike
Posts: 3829
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: my decal issue

Post by JackGriffin »

You have to assign the proper code to the child spawns too. They may be spawned by the parent function but they don't automatically inherit the variables.

Code: Select all

Spawn(EnergyImpact,,,HitLocation+HitNormal, rotator(HitNormal))
You might also need checks before that like this:

Code: Select all

if ( (EnergyImpact != None) && (Level.NetMode != NM_DedicatedServer) )
because sometimes the decal will spawn like crazy when tested online. This will limit it to one.
So long, and thanks for all the fish
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: my decal issue

Post by >@tack!< »

JackGriffin wrote:You have to assign the proper code to the child spawns too. They may be spawned by the parent function but they don't automatically inherit the variables.

Code: Select all

Spawn(EnergyImpact,,,HitLocation+HitNormal, rotator(HitNormal))
i thought it does inherit cuz the other FX do have the good rotation and location, and anyway that code cant be done in the FXclass, but can be done in the shockrifleclass and that didnt fix my problem.

JackGriffin wrote:You might also need checks before that like this:

Code: Select all

if ( (EnergyImpact != None) && (Level.NetMode != NM_DedicatedServer) )
because sometimes the decal will spawn like crazy when tested online. This will limit it to one.
I tried this too tough EnergyImpact != none caused an error so i tried Spawn(class'EnergyImpact') != none
also doesnt work.

I see this in the UT_WallHit class

Code: Select all

class UT_WallHit extends BulletImpact;

var int MaxChips, MaxSparks;
var float ChipOdds;
var rotator RealRotation;

replication
{
	// Things the server should send to the client.
	unreliable if( Role==ROLE_Authority )
		RealRotation;
}
...
...
Auto State StartUp
{
	simulated function Tick(float DeltaTime)
	{
		if ( Instigator != None )
			MakeNoise(0.3);
		if ( Role == ROLE_Authority )
			RealRotation = Rotation;
		else
			SetRotation(RealRotation);
		
		if ( Level.NetMode != NM_DedicatedServer )
			SpawnEffects();
		Disable('Tick');
	}
}
Does RealRotation have something to do with my problem??
JackGriffin
Godlike
Posts: 3829
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: my decal issue

Post by JackGriffin »

Sorry, my bad. I thought EnergyImpact was a custom class. I didn't recognize it. I looked and the class supers to decal, which won't carry the location data. You'll have to manually assign that

Look at the code from ShockProj:

Code: Select all

simulated function HitWall (vector HitNormal, actor Wall)
{
    if ( Role == ROLE_Authority )
    {
      ***SNIP***
    }
    Explode(Location + ExploWallOut * HitNormal, HitNormal);

//THE GOOD STUFF:
    if ( (ExplosionDecal != None) && (Level.NetMode != NM_DedicatedServer) )
        Spawn(ExplosionDecal,self,,Location, rotator(HitNormal));
}

See how it sets the decal location? Remember decals won't render unless they can attach to something. Your decal is still being spawned, you just don't see it because it has no surface.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5502
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: my decal issue

Post by Feralidragon »

The key for that is bNetOptional=True (somewhat the actor is created on the server and clients independently, and each one runs its version, however it won't be even spawned client-side if there's not enough bandwidth to, but that's not a problem nowadays, unless you still have a 56k modem connection or the server starts to lag), but it must be set as default property.

Also, you must note that Rotation is not replicated if your effect is a sprite, it's only replicated if it's a mesh, so by spawning anything from a sprite actor online, its rotation will be always the same: rot(0,0,0).
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: my decal issue

Post by >@tack!< »

bNetOptional has to be true or false? for the decal or the actor that spawns the decal?
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: my decal issue

Post by >@tack!< »

woot nevermind guys thx anyway, i fixed it by looking in the UT_superring and UT_Superring5 class which uses a bool or sth, now it is spawned in every rotation and always yay, 1 problem left, which im still trying to fix myself now but i might ask it here too :p