VPhysics initialization stage in BaseEntity

Grab your favourite IDE and tinker with the innards of game engines

VPhysics initialization stage in BaseEntity

Postby chillok on Thu Nov 11, 2010 11:45 pm

I've got a think function in BaseEntity looping which I want to access the mass of the entity via:

Code:

Code: Select all
IPhysicsObject *pPhysics_this = this->VPhysicsGetObject();
float mass = pPhysics_this->GetMass();


But the problem is pPhysics_this is null.
In other portions of the program this code works fine, but in the think function it doesn't.

Does anyone have an idea why?

[thinking something about the VPhysicsObject maybe not initialized (or is destroyed) at the time the think is called, but not sure]
chillok
Dumpling
Dumpling
 
Joined: Mon Sep 27, 2010 7:11 pm

Re: VPhysics initialization stage in BaseEntity

Postby omnicoder on Fri Nov 12, 2010 12:29 am

If you enclose it in
Code: Select all
if (this->VPhysicsGetObject())
{
//Code here
}

does it work?
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: VPhysics initialization stage in BaseEntity

Postby chillok on Fri Nov 12, 2010 1:01 am

Sorry, no. The VPhysicsObject is always null (in the think function). I have no idea why. I've used the code in different situations where an event calls the method which exceutes the code (eg, bullet hitting entity), all in the same class BaseEntity, which works fine.

I wonder if, at the time that BaseEntity calls it's think functions, that the VPhysics is either not declared yet or is destroyed. It doesn't make much sense that it would be the case.

[I want to use the VPhysics pretty much solely to get the mass of an Entity, and yep it does need to be looping.]
chillok
Dumpling
Dumpling
 
Joined: Mon Sep 27, 2010 7:11 pm

Re: VPhysics initialization stage in BaseEntity

Postby omnicoder on Fri Nov 12, 2010 1:15 am

chillok wrote:Sorry, no. The VPhysicsObject is always null (in the think function). I have no idea why. I've used the code in different situations where an event calls the method which exceutes the code (eg, bullet hitting entity), all in the same class BaseEntity, which works fine.

I wonder if, at the time that BaseEntity calls it's think functions, that the VPhysics is either not declared yet or is destroyed. It doesn't make much sense that it would be the case.

[I want to use the VPhysics pretty much solely to get the mass of an Entity, and yep it does need to be looping.]

Oh I had been assuming that it might have only been a problem for the initial think which the above code would have fixed. I'll step through the dlls and see whats nulling it for Think.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Return to Programming

Who is online

Users browsing this forum: No registered users