Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


ryt

Member Since 03 Sep 2005
Offline Last Active Mar 01 2014 02:38 PM

Topics I've Started

Accessing enum from inherited class

24 January 2014 - 04:10 PM

In C# in my base class Weapon I have declared a enum Firestate like:

enum Firestate
{
    Fire
};
 
public class Weapon : MonoBehaviour
{
    public Firestate firestate;
};

And in a inherited class Gun I use that enum. But I get error CS0052: Inconsistent accessibility: field type 'Firestate' is less accessible than field 'Weapon.firestate'.
When I remove public from firestate there is no error but then I cant use it in Gun since it is private.


Naming conventions for math statements

23 January 2014 - 03:31 PM

How do you write variables for math names ?

For vectors for example I sometimes append v like vLocalPosition. But for some common vectors I use names like pos, dir, dist. Also for coords I sometimes use forward, up, right.

For matrices I append m in front or try to use a single uppercase letter like M.

 

How do you write names for transformations and rotations ?

Names like transformAirplane or rotationCar seem a little cumbersome.


Branching in switch statement

22 January 2014 - 03:24 PM

Is it possible to jump from a switch statement to another switch statement without leaving the current switch in C# ?


Colliding position

19 January 2014 - 02:23 PM

I have two objects and I want to find when will they collide. Lets say first target has position p0, velocity v0 and the time it will arrive at desired position is t0. Similar for the second target it has position p1, velocity v1 and the time t1.

The general formula for speed with constant velocity is:

 

p = v*t + p0

 

So if we try to find their colliding position p0 and p1 should be equal at desired time so p0 = p1.

 

v1 * t1 + p1 = v2 * t2 + p2

 

t2 = v1 * t1 + p1 - p2 / v2

 

t2 is the time that will second object arrive at colliding position.

I wonder how we can calculate this ? On the right hand side of last equation we have vector division. So since t2 is a scalar on the right hand side there also must be a scalar. So I think we should take the magnitude of vectors on right side and divide them.

What to do in these situations when we have a division of two vectors ? Is this approach correct one ?


Accessing base class functions

16 January 2014 - 03:21 PM

In C# in the inherited class we could access base class functions with keyword base like:

void SomeFunction()
{
	base.Move();
}

How can we do this in C++ ?


PARTNERS