Problem with RenderParticles properties and variables with similar names

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 733
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Problem with RenderParticles properties and variables with similar names

Post by Ats »

Hello,

I have this float named "Speed" since forever in my game, and I also always have this problem with RenderParticles:OnEmitExpression component saying: Invalid conversion: float(Speed))

So I converted Speed to SpeedRounded (int), because of that error message, and everything was fine. But I suspected that was weird, since the RenderParticles properties are float.

Today, I dug a little, and it turns out that float/int wasn't the problem! The bug is that RenderParticles:OnEmitExpression can't tell the difference between the RenderParticles properties and the name of the var:

this.Speed = Player.Speed; // BUG!

I made a really small example:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
  <OnUpdate>
    <ZExpression>
      <Expression>
<![CDATA[
Speed = 5.5;
VarInt = Speed;]]>
      </Expression>
    </ZExpression>
  </OnUpdate>
  <OnRender>
    <RenderParticles ParticlesPerSecond="50" Spread="3.14" ParticleWidth="0.01" ParticleHeight="0.01" Speed="2.75" ParticleLifetime="2" AnimateSize="0.1">
      <OnEmitExpression>
<![CDATA[//Emit particle.
//PColor : particle color, PAngle : particle angle

//Speed = VarInt;
this.Speed = Speed;]]>
      </OnEmitExpression>
    </RenderParticles>
  </OnRender>
  <Content>
    <Variable Name="VarInt" Type="1"/>
    <Variable Name="Speed"/>
  </Content>
</ZApplication>
I know that in ZGE, two Models can't have the same variable name in their Definitions. But here, it is a component property.
This is preventing users to have variables named "Speed", "Direction" or "Gravity" in their projects if they are using a RenderParticles component and want to plug the RenderParticles properties to those variables.

So I was wondering if this was normal before renaming all my variables to more personal nicknames such as "MySpeed"?
Post Reply