May 22, 2012, 04:59:15 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Adding Objects  (Read 1324 times)
Squat
Hero Member
*****
Posts: 592


View Profile
« on: September 01, 2008, 01:56:50 AM »

What's going on with addobject that when i choose objects with mass nothing happens? It works perfectly fine on all the other objects but player objects and ones with mass. Is that normal?

Setting the mass to zero on an object that's coded with addobject causes the object to properly be added. As soon as mass is > 0, it stops spawning.

« Last Edit: September 01, 2008, 01:58:43 AM by Squat » Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #1 on: September 02, 2008, 12:06:42 PM »

I don't want to start a new thread for every line of code I can't figure out, so I'll keep going on this one.

I can't get anything work to set the scale on an object through script. I tried GetMatrix().SetScale(vector); with nada.

Is there away to script the 'Normal Offset' parameter in the surface properties? If not, can I please ask for a priority feature request? This would be SO useful for so many things, like my brilliant scheme, combining it with non-uniform scale to make things melt.
« Last Edit: September 02, 2008, 12:10:23 PM by Squat » Logged
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #2 on: September 02, 2008, 12:39:55 PM »

Well i dont know what could cause but if it is a bug maybe you can set mass after you have spawn it? I dont really know the code for it but there should be a SetObjectMass or something Smiley
Logged
zknack
Full Member
***
Posts: 207


View Profile
« Reply #3 on: September 02, 2008, 12:50:52 PM »

If I'm understanding you correctly, you want to be able to scale something up or down in-game?

Home ? Reference - Object Properties ? Object Properties ? Objects ? LoadObject     - objectscale
ObjectScale
  • [y] [z]

Specifies the scale of this object. Must be preceded by 'LoadObject'.
NOTE: Use of this option is not recommended for full production. It is meant to be used as a convenient way to size-up your objects... once the proper object scale is found, please remove this option from the OPR and scale your models as appropriate in your modeling program.


You *can* set the objects .opr file as write-able, and have an object, say a bounding box, weapon, etc- change the value of the
objectscale property line in your opr file, on the fly, in-game.

Just an idea?
Logged
gekido
Guest
« Reply #4 on: September 08, 2008, 12:19:47 AM »

if you are modifying an object's position / rotation etc from script and the object is controlled by the physics system then you may need to call a couple of functions to sync the physics simulation with the changes that you've done.

object.UpdateCollisionObjectPositions();

and

object.ResetCollisionObjectVelocities();

Here's the docs pages for these two functions (however brief they are atm):

[updated docs links to valid / current docs pages]
http://www.gamecore3d.com/docs/scripting-reference/classes/Object/UpdateCollisionObjectPositions

http://www.gamecore3d.com/docs/scripting-reference/classes/Object/ResetCollisionObjectVelocities
« Last Edit: May 20, 2009, 12:51:39 PM by gekido » Logged
hikmayan
Full Member
***
Posts: 231



View Profile
« Reply #5 on: September 08, 2008, 02:10:21 AM »

This is really helpful in terms of the collision not updating when "object is re-scale" for example.
Logged

You have to be in it.....to win it!
gekido
Guest
« Reply #6 on: September 09, 2008, 12:30:36 AM »

yeah basically if you don't call the functions to sync the physics system, what happens is that you do the change in your script and then the next dynamics step the physics overrides it and moves it back where it was before - since the physics system doesn't know that you wanted it moved yet, it continues along it's merry way until you tell it "um hello, we moved this object over here m'kay?"
Logged
hikmayan
Full Member
***
Posts: 231



View Profile
« Reply #7 on: September 09, 2008, 06:36:45 AM »

"um hello, we moved this object over here m'kay?"

OK!....0__0, thanks a lot....I get it!
 
Logged

You have to be in it.....to win it!
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #8 on: September 09, 2008, 02:07:03 PM »

I'll keep at this. When I left it, I was trying to merely add a brand new object to the world when I jumped in an input area. If I added one that had no mass, it popped in at the calling object's origin, if the object had mass it didn't show up.

I tried to set the position before spawning and after and I could of sworn I added the lines to update the collisions but it's not in my code now so either I dumped it or never got it in. Either way, shouldn't the object at least show up?

I know you have to reset the collisions when you move the object, but wouldn't all that be set when it spawns?

BTW, I think we can improve the platform elevators if we run some checks on what's on the platform and update those collisions aswell. At least that way physics objects won't drop through and maybe we can even retain good control while it's moving. I would like to start getting a handle on how to work with object collisions quite soon so I can stop using input boxes.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #9 on: January 17, 2009, 08:57:47 PM »

I have a brand new question about adding objects. It appears that if I add a simple_bad_guy_controller dynamically within the game (by way of addobject), I get a fatal exception error.

This is obviously due to the fact that the controller object I'm adding is told, itself, to add another object, the bad guy AI. So I need to load an object and tell it what script to run.

Is that possible?

Also, obviously, I can add the AI character directly itself, but he doesn't do anything liek the ones added by the controller.

Can we actually alter what script is associated with an object on the fly?
Logged
Ron
Sr. Member
****
Posts: 326


View Profile
« Reply #10 on: January 18, 2009, 12:53:22 AM »

Not sure if it helps or not, but here is how I am adding ai vehicles

create a "player"
addobject opr (no geometry) which calls the script the has aiscript in it. This is a very simple opr file, not much disk space, just has collisions and joints
addobject opr that is the vehicle body (this opr does call a script file so it can work to add to player inventory, but the script file is empty except one blank line)
addobject opr wheels (same as above, calls a empty script file)
addobject opr driver....

add all the above to the player inventory

I imagine you could have different first opr's, each containing references to different ai scripts and you could dynamically add and remove from inventory as you wanted to change behavior. This opr is ver small since it doesn't add any of the 3D geometry like those in the oprs that follow it.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #11 on: January 19, 2009, 03:39:58 PM »

Yeah, there's a little more to it than I first thought. I haven't figured it out fully yet, but I did get a decent spawning system in regardless. In the end, I noticed that there is a relatively large and noticable pause in the game the instant that an AI entity is spawned (addobject) into the world.

However, if he's spawned in the beginning, hidden and then shown at the right times, he's disabled while hidden and appears to come out of nowhwere without an ounce of hickup when he's activated. So, truthfully I don't quite need this at the moment.

HOWEVER, I am exploring a way to dynamically load and unload AI entities into the world without having to hand-place 1000 hidden ones. I'm still quite unsure how groups are being defined and handled, but I know there's a lot of power to be had from that so I'll be looking into it more.

Just a note about what I did:

1) I took the bad_guy_controller.gsl and duplicated it

2) I took the parts of PostInitialize that started its actions and put it into a handleEvent.

3) I rerouted the position of where he spawns by layering in a controller variable for "SpawnHere" that points to any object in the world the user types in. The code already lined up the AI bot to the bad_guy_controller object, I just pointed that elsewhere.

4) I set him to hide first thing.

5) On input, I set him to show and wander path. I put a hardline path right from where he spawns to right where the player triggers him. It's taking a long time, but the great news is that I've developed it into a system where if you run down a corridor, AI enemies are constantly lining up around the corner and charging at you. If you stop, they're gone.

6) The controller now checks both the player's "IsDead" and the characterObject's (AI). When the AI dies, it waits for a new controllersetting "TimeToLive" and then deletes the characterObject and then itself (bad_guy_controller) and breaks the script right after.

So, right now it's one of those games where you clear them out and they're gone. I have absolutely NO lag save for what's already been there from my missing LOD's and overuse of renderobject collisions.
Logged
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #12 on: January 20, 2009, 05:10:36 AM »

squat i am amazed how much you have learnt and incorporated. you really seem to have a flow Smiley
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #13 on: January 20, 2009, 02:18:41 PM »

Thanks Pixel, but I am standing on the shoulders of giants.
Logged
gekido
Guest
« Reply #14 on: May 20, 2009, 12:54:01 PM »

The 'large and noticeable lag' is basically the engine loading the object & any associated textures that might be required.  The trick to get around this is to include a 'hidden' version of any objects that your worlds might require (ie are spawned dynamically) in the world when it is originally loaded. 

This way whenever you 'spawn' something, the object & textures are already loaded into memory and it just needs to be instanced - which happens almost instantaneously.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!