Problem moving an object in room

Started by tiagocorreia, Fri 14/07/2006 09:57:39

Previous topic - Next topic

tiagocorreia

Hi,

I've a cutscene that happens after I give an inventory item to a character. After that I run several moves and animations with the characters. I would also want to move, and should objects that are in the room where the character is.

So i've created 4 variables Objects* variables that are assigned, the first time the player enters in the room, inside a module I created.

Then the first time 2 of the object I can use them without any problem, but other 2 I got this error.
Quote
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x004400DE ; program pointer is +77, ACI version 2.72.920, gtags (7,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

in Game Functions (line 1206)
from Global script (line 1234)

What I do is the follwing:
Code: ags

		this.objLog.SetPosition(424, 427);
		this.objLog.Visible = true;
		Wait(10);
line 1206  -->	this.objLog.Move(387, 241, 1, eBlock, eAnywhere);


I've no ideia why this happens.

Edit:

I've tried other ways of solving the problem, but the problem remains

I've now, just tried a simple thing:
On first time player enters the room
Code: ags

object[3].Move(50,50,1,eNoBlock,eAnywhere);


Quote
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x004400DE ; program pointer is +6, ACI version 2.72.920, gtags (11,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

in Room 1 script (line 227)

Edit 2:

I've done further diagonst, and I think the problem is on the Move function. It doesn't work for any object in this room. But for other objects in other rooms, it works. this is very strange.

SSH

The objects probably get destoryed and recreated every time the room is loaded, so the pointers will be invalid when you re-enter the room. You will need to set your global pointers EVERY TIME the room in enetered, not jsut the first.
12

tiagocorreia

And if I use this?

Code: ags

object[3].Move(....)


Should I also get an error? Because the error is only on the Move, i can do SetVisible, SetPosition.

Radiant

object[3] refers to the standard objects in a room, specifically, the fourth object (because numbering starts at zero). If in the room editor you have not declared at least four objects, I'd expect this to cause errors.

The solution to your earlier problem would probably be to declare the Objects* outside the function, so that they persist across function calls.

Are the objects on a walkable? It might help.

SSH

Put an "if (object[3]!=null)" before your move to make sure that that is not the problem...
12

tiagocorreia

I've tried to put the "if (object[3]!=null)", at it gives me the same error and it is still on the line of the Move function.

---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x004400DE ; program pointer is +77, ACI version 2.72.920, gtags (7,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

in Global script (line 1292)


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
---------------------------
OK   
---------------------------

Radiant

I notice the line number in your error is different in each example. In particular, in the last case you seem to be handling objects from the global script. While technically there's no reason why you shouldn't do that, it's not necessarily a good idea because the game might be in a room that has fewer objects, or if you run from game_start the game might not even be in any room yet.

tiagocorreia

I run this scritp after I give an object to a particular character, that is always in the same room.

When this fucntion triggered, I've 100% sure that the charcter and player and objects are there, since this is run, after i give an inventory object to a character in a room.

Each example has different line numbers, because I've been adding some lines before and after to try find out the problem, but it always crash in the Move function.

SSH

You could also try checking that the objet isnt already moving, as you would need to sto it moving first...
12

Pumaman

Could you upload a small sample game that demonstrates the crash?

tiagocorreia

#10
Nope, it was not moving.

I tried to had a StopMoving() before, but I I did get the same error on Moving.

Edit:

I can try to do a small example. Because, curently, my game is quite big and complex. I'll try to make a smaller version.

strazer

Please try not to double-post. You can use the "Modify" button to edit your posts.

Gilbert

In fact, just uploading the room file may help already, you can even change its bg to black of the same res to make it smaller.

tiagocorreia

I managed to solve my problem, by using characters instead of objects.

SMF spam blocked by CleanTalk