About Store Forum Documentation Contact



Post Reply 
[solved] Absurd Create Bug
Author Message
AndrewBGS Offline
Member

Post: #1
[solved] Absurd Create Bug
I'm really pissed about this one, today I did nothing all day but trying to fix this.
I'm dynamically creating a map. Placing some blocks on a map; that easy.
In my block's CREATE function, I set some parameters:
x=pos().x; y=pos().z; (awesome, I know.)

Now with my amazing degub system, it turns out that for 2 of my 3 blocks generated, those parameters are both 0 in the update function (bare with me...). The 3rd of the blocks, has the parameters of the 1st (the position).

Now if not for the next thing, I'd believe I'm just doing something wrong. BUT, I have a magic restart button for my game. If I press it, I call clear() on all world containers, and generate the map again (the same 2 functions I call in the GameInit()). And this time, every single block displays correct coordinates, and everything works just perfectly. I looked up that reset code, everything contained in there is in the GameInit also. No idea what's going on.

Could anyone help?


FIXED:
(One day of messing my brains with this one, and I fix it 10 minutes after making a post....)
Apparently when I use Game.World.ObjCreate() the object is NOT created at the coordinates I give it (as I assumed) but instead is created at (0,0,0), so setting my coordinates in the create function was always making my block appear to be at (0,0,0). Wish this was explained in the Game.World.ObjCreate() comment.
(This post was last modified: 09-04-2013 07:27 PM by AndrewBGS.)
09-04-2013 06:53 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #2
RE: [solved] Absurd Create Bug
(09-04-2013 06:53 PM)AndrewBGS Wrote:  ...
Apparently when I use Game.World.ObjCreate() the object is NOT created at the coordinates I give it (as I assumed) but instead is created at (0,0,0), so setting my coordinates in the create function was always making my block appear to be at (0,0,0). Wish this was explained in the Game.World.ObjCreate() comment.

I don't understand this ... when I use objCreate or objCreateNear my object is placed at the co-ordinates I specify ... not at the origin!

example:

Code:
// Create the new NPC object and return a pointer to it (This also adds it to the
// npcObjs collection by virtue of its type).  Note the transformation of the z axis here    
Game::Obj* myObj = Game::World.objCreateNear(*obj, Matrix(obj->scale(), Vec(position.x,position.y+1,-position.z)));
09-05-2013 06:26 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #3
RE: [solved] Absurd Create Bug
Maybe it's because I didn't use createNEAR then. Might have been an idea.
09-05-2013 08:16 PM
Find all posts by this user Quote this message in a reply
Post Reply