Code Debug Help

  • 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.

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
Hi my problem is thus, i wrote a small testing program that would simply change the size of an object when an actor approaches (see script)

Code:
//==============================================================================
// Object Scalar: changes scale of an object depending on player proximity
// Created by Rich_Zap
//==============================================================================
Class ObjectScaler extends Trigger Placeable;

var float minsize;
var bool bdetect;
var() float maxsize;
var float currentscale;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

	currentscale=DrawScale;
	
	if ( TriggerType == TT_PlayerProximity)
		bdetect=True;
	if ( bdetect && (currentscale<maxsize) && (currentscale>minsize))
		SetDrawScale(currentscale-1);
	if ( !bdetect && (currentscale<maxsize) && (currentscale>minsize))
		SetDrawScale(currentscale+1);
	
}

defaultproperties
{
	bdetect=False
	DrawType=DT_StaticMesh
        StaticMesh=StaticMesh'AlleriaHardware.ALgPipe03AL'
	minsize = DrawScale
	maxsize = 2
}

My Object Scaler compiled correctly however when i come to place one in the editor nothing appears. Can someone please tell me what my noobie mistake is ?

EDIT: I have updated to my current code.
 
Last edited:

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
No, sorry it compiled but still wont show when i try to place it.

EDIT: Aha i found the noobie mistake XD I forgot that when i specified it as a DT_StaticMesh i actually needed a default SM. It shows up in the editor now and that all works ok but it doesnt show ingame does anyone have any idea why this could be ?
 
Last edited:

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
Your script wont work becasue PostBeginPlay only gets called once, at the beginning of the level. Therefore, since it only gets called once, it will only change size once (and my guess is that its changing size to DrawScale = 0, which means it wont draw, thus you wont see it).
 

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
Yes, but the real concept behind uscript is that most of the time, all of your actors should be idle. Tick() is called every tick (hence the name), and gets passed into it the time elapsed since the last tick (DeltaTime). You could, in theory, use that, but you would be doing a lot of extra work, and would be writing sloppy code for frivolous reasons. A better way would be to use Touch and Untouch (which get called by the engine when some other actor comes within and leaves the collision radius of another actor, respectively (assuming there is a collision cylinder set up, and the actor is using it). Instead of checking every tick, let the engine tell you when something happens.

Also, how in your code are you determining if the player is near or far? And why did you extend Trigger? I guess your logic was that if the player is near, the trigger gets triggered, which isnt necessarily true.
 

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
fair enough, im a noob to coding in someone elses program as i stated though :). But you are right, that would be sloppy coding so would i call Touch instead then ?

I assumed that because my object would be an event that would work much like a trigger that it should extend trigger. However in hindsight it would make sense to have an actor that expands once it is triggered and have a trigger to actually do the erm ... triggering. Well thanks for the help guys, i think i understand a bit better now, back to the old drawing board :).
 

draconx

RuneUT
Jun 26, 2002
325
0
0
36
Waterloo, Canada
These are in the UT trigger class, i'm sure they're there in 2K4 too.
Code:
function Touch( actor Other );
function UnTouch( actor Other );
Called when an actor enters or leaves the trigger's radius.

Edit: erm misread your prev post due to lack of sleep. Going to bed now :D
 
Last edited: