View Full Version : Int incompatible with -= ?
01-21-2012, 06:37 AM
So, Meshes[CenterAmount].location.x -= (i*64) / 2;
So, I got an array of meshes, called meshes. CenterAmount is an int, and I is an iterator.
The meshes are spawned through the iterator.
What I am trying to do here. Is, on the right side, get the center point, and on the left side, subtract the amount.
However, It is giving me that the left side is incompatible with -= ? I don't get it, it's just an int?
01-21-2012, 06:59 AM
Location is constant, you have to use SetLocation(newVector)
01-21-2012, 12:23 PM
Ah, thanks. It's compiling just fine now.
It's still not working as it should though, maybe you could have a look?
class SMButton extends Actor placeable;
var Actor Actors;
var array<DynamicSMActor_Spawnable> Meshes;
var() string Text;
var rotator LetterRotation;
var string LetterPackage;
var int CenterAmount, TextSize;
var vector CenterToVector;
local int i, offset;
local array<string> strarr;
local vector LetterLocation;
for(i = 0; i < Len(Text); i++)
strarr[i] = Mid(Text, i, 1);
if(Asc(Caps(strarr[i])) == Asc(strarr[i]))
`log("Capital Letter Found!");
LetterPackage = "Symbols_Capital";
LetterPackage = "Symbols";
LetterLocation = Actors.location;
LetterLocation.x += (i+offset) * TextSize;
LetterRotation.pitch = 0;
LetterRotation.roll = 50 * DEGTOUNRROT;
LetterRotation.yaw = 0;
Meshes[i] = spawn(class'DynamicSMActor_Spawnable');
Meshes[i].SetStaticMesh(StaticMesh(DynamicLoadObject(Letter Package$strarr[i], class'StaticMesh')), LetterLocation, LetterRotation);
CenterToVector.X = (i*64) / 2;
for(CenterAmount = 0; CenterAmount < Meshes.length; CenterAmount++)
TextSize = 64
The idea is to spawn models of letters based on a string, this is done by iterating through every letter of the string, finding the appropriate package and spawning the mesh by the same name as the letter.
The packages has been set up, and it complies fine. However, no model is present when the actor is placed in the scene. Any suggestions why that might be?
(Note that this is not originally my code, though I have tailored it for my use and I know how to use it and how it works, the original was kinly given by DerpFace)
01-22-2012, 02:27 AM
You don't seem to have actually setup the Actors variable to point to any particular actor. Also, this would not run in editor, only components that are declared in defaultproperties will show up in editor, as code does not run in editor.
01-22-2012, 05:33 AM
Ah, good point. I didn't think of that.
Edit: Tested it ingame, not visible there either I am afraid.
As for the actor variable, that's the one thing I am unsure about what his intention were. I noticed that myself.
I am assuming it's just leftover coding from the prototyping phase. I'll just remove it.
01-22-2012, 07:09 AM
SetLocation(CenterToVector) appears to overwrite the location previously set with LetterLocation. In other words the centering code is just moving the letter to (X=(i*64)/2, Y=0, Z=0).
01-22-2012, 07:39 AM
Shouldn't it be moving the entire array?
01-22-2012, 09:22 AM
It's looping through all the items in the array and setting each item location to CenterToVector. The only other reference to CenterToVector I can see is to update the X property, not Y or Z which by default will be 0. As it stands the result is to completely overwrite the work that LetterLocation does.
Not sure what the purpose of the CenterAmount loop is (is it meant to center each letter, or align the whole text?), but you probably should append the calc to LetterLocation, something like this:
LetterLocation.x += (i+offset) * TextSize + (i*64)/2;
The CenterAmount loop is also inside the Letter spawing loop, so it's being repeated over and over again.
01-22-2012, 09:31 AM
I just looked at the old thread and the above should work for you by replacing the +(i*64)/2 with just -32 :)
And remove the the CenterToVector, and CenterAmount loop.
Edit: bah, it's confusing me now lol
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.