how to cause a action to happen by pressing a button and collision physics question

This post has 16 Replies | 5 Followers

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee
jeffery Posted: 03-25-2012 7:23 PM

I have a two part question how can i cause an action to happen like a door opeing up by pressing a button when i get near it? Also, the second part of the question is how to throw a object into a hole (the hole is a  simple hollow 3d box object with no top for first test) and trigger an event like a round object thats small enough to fit in it and when the trigger event is executed cause an explosion.

Sorry if im posting weird questions but I need to know this because my main platforms will be windows and xbox 360 and i will have a large game file probably when im done because of the video except on windows phone because i can host the video on a secured server if necessary and i do plan on releasing on windows phone 7 also.

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Trigger components :-)

jeffery:
how can i cause an action to happen like a door opeing up by pressing a button when i get near it?

Try creating a box and set it to not render in the editor and then attach a trigger to it.

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi guys,

If you grab the Light Mapping or Dojo examples they contain a CollisionEntity, which you can place in the scene, adjust its size, and setup collision / trigger info for.  Thinking about it we should probably move that class into the core engine. :)

To drop an object in game create a new SceneObject, set its UpdateType to automatic, set the CollisionType to collide, AffectedByGravity to true, and the object will fall in place and collide with the world.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

question but how would i cause the hollow box to explode using particle physics for instance when the grenade goes through it (it will be visible)?

Also, dseb how would you recommend doing the open door animation after i press the button? I suppose i could put another property into my class that could help me to know if the button has been pressed but  how would I draw the animation to open the door because i believe i would be hard but if I have blender i can use if i need to and i like blenders new interface.

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

Any ideas on what settings to use for particle physics explosions?

Also, I tryed the suggestions for the door but when i do the windows code version it doesnt respond to anything and freezes but if i remove keyboard code check it works fine can anyone help me out with it? I will post an edit later today when i get off of work.

Top 10 Contributor
Posts 513
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

You will need to write this yourself.

Alternatively, have a look at the Mercury Particle Engine. Philippe has already implemented this in the indie game freaks framework http://indiefreaks.com/indiefreaks-game-framework/

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

thanks i already had phillipes dlls included with the video project so it would be a matter of just using the framework correctly.

I already posted their but  if you can provide me a link to the sample for particles I thought i remember him having one but if you know how a simple explosion would be done minus the nice smoke just particles part i would be happy.

But for sure can you post the video tutorial about particles and the codeplex page where he posts the soure for it (this more preffered)?

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

I have no particle tutorial up yet but it'll come soon. Until then, you may want to buy Ace on Steroids and therefore get a copy of the game source code which includes particle systems for explosions. It's available on Indievania.com or IndieCity.com for now: your choice ;)

Philippe

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

Philippe Da Silva:

I have no particle tutorial up yet but it'll come soon. Until then, you may want to buy Ace on Steroids and therefore get a copy of the game source code which includes particle systems for explosions. It's available on Indievania.com or IndieCity.com for now: your choice ;)

Philippe

 

Darn i wanted source also for xbox and windows phone.

Phillipe can you integrate databases into your xbox xna dll file? I found this source which is in xna 4 at least but you need to remove bad frontend integration but code all their just need some changing and it would be a great addition to your library:

http://code.google.com/p/fracture/source/browse/#svn/trunk/Squared/XNASQLite

Think you can release this in next igf release and give a tutorial with source on using it?

Its a c# xna compatible port of SQLite. I wish to write an in-game editor for the player to create their own missions and campaign scenarios.

 

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

I have a problem with the button code it appears it will not work when i walk up to the door i press enter and the door disappears instead of a fancy open animation for my first test and then i can walk through it but instead i cant walk through it. Maybe im playing code wrong because if i remove the keyboard check it just removes the door and i can walk through it but underwise I cant walk through it.

Top 10 Contributor
Posts 1,128
SunBurn_Community_Licensee
SunBurn_Contributor

jeffery:
Phillipe can you integrate databases into your xbox xna dll file? I found this source which is in xna 4 at least but you need to remove bad frontend integration but code all their just need some changing and it would be a great addition to your library:

You could always download the IGF source code and implement it yourself.  Please remember that people may have many other commitments (like day jobs) as well.

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

Okay sorry but i have tryed to figure out his source but theirs no documentation whatsoever on it otherwise i would have tryed and already had it finished.  

Okay but to get back to the thread discussion i have a picture of how it makes the door disappear correctly but i cant go through it:

 

Okay Heres the code i've got from the update method in game1:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

KeyboardState

 

 

keyboard = Keyboard.GetState();

 

 

 

if (keyboard.IsKeyDown(Keys.Enter))

{

 

 

 

publicvars2.opendoor = true;

}

 

 

 

if (publicvars2.opendoor == true)

{

sceneInterface.ObjectManager.Find(

 

"door_01", false, out obj);

obj.Visibility =

 

ObjectVisibility.None;

obj.CollisionType = SynapseGaming.LightingSystem.Collision.CollisionType.None;

 

 

 

//obj.HullType = HullType.Mesh;

 

 

 

//sceneInterface.ObjectManager.Find("door2", false, out obj);

 

 

 

//obj.Visibility = ObjectVisibility.RenderedInEditor;

 

 

 

//obj.CollisionType = SynapseGaming.LightingSystem.Collision.CollisionType.None;

sceneInterface.ObjectManager.Find(

 

 

"opendoor", false, out obj);

obj.Visibility =

 

ObjectVisibility.RenderedInEditor;

obj.CollisionType = SynapseGaming.LightingSystem.Collision.

 

CollisionType.None;

obj.HullType = 

 

HullType.Box;

}

heres the component trigger code:

 

 

private void OnTrigger(IMovableObject collider, IMovableObject trigger)

{

i = i + 1;

 

 

// handle trigger response here... PassThrough.LevelPoints += PassThrough.PointsSmall;

 

 

 

if (i < 2)

{

#if

 

 

XBOX

SystemConsole.AddMessage("press a to open door", 10);

#endif

#if

 

 

WINDOWS

 

 

 

//KeyboardState keyboard = Keyboard.GetState();

 

 

SystemConsole.AddMessage("press enter to open door", 4);

 

 

//if (keyboard.IsKeyDown(Keys.Enter))

 

 

//{

 

 

// publicvars2.opendoor = true;

 

 

//}

 

#endif

#if

 

 

WINDOWS_PHONE

SystemConsole.AddMessage("tap screen to open door",10);

#endif

 

}

 

 

else

{

 

 

 

return;

}

 

 

// Drawing to the rectangle will stretch the

 

 

// video to fill the screen

 

 

 

// Draw the video, if we have a texture to draw.

 

 

}

}

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

Phillipe will that code work in my 3d environment also? Im trying to make the box explode upward then out from all sides in 3d environment. Anyone with anyhelp with the door key button press i've almost gotten that done but when i press enter the door disappears instead of a fancy animation but i cant go through it can i tell my trigger object to stop receiving updates once its triggered? I think that might be the problem.

 

 

 

 

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

Anyone have any ideas? I cant get the enter button to work on windows but if i leave it out and set the publivars2.dooropen variable to true manually in code it works could it be im doing something wrong somewhere?

Im creating a codeplex page so i can upload full source code and people can easily see where im going with source code.

Top 50 Contributor
Posts 94
SunBurn_Pro_Licensee

I will upload source to this codeplex page and see if anyone can see what im doing wrong:

http://sunburncustomsamples.codeplex.com

Also, i keep adding complexity to the projects as i go along because I wish the sunburn community to learn how to do something advanced so they can progress as I do and I want eventually to create sample tutorials that work like phillipes except focus on 3d aspects.

 

Page 1 of 2 (17 items) 1 2 Next > | RSS