My Collision Problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

My Collision Problem

Post by dejai »

Ok, now I want the camera to move or be repositioned when it hits a certain corrd

Code: Select all

   scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
   
   if (camera)
   {
            camera->setPosition(vector3df(0,150,-100));
            camera->setRotation(vector3df(0,90,0));
            vector3df position = camera->getPosition();
           vector3df wall_1 = vector3df(0,100,-100);
           
           if (wall_1 == position)
           {
                   
           camera->setPosition(vector3df(0,100,0));    
           }
           
        
   }

Now, I want this line of code

Code: Select all

           if (wall_1 == position)
           {
                   
           camera->setPosition(vector3df(0,100,0));    
           }
           
to only apply to the middle level z

so no matter where i am say 34,100,2
or 734,100,2 it will always stop the camera

so whenever the camera gets to the point 100 on axis z it just stops.
Programming Blog: http://www.uberwolf.com
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Do you know the concept of continuing a previous thread?
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Also how do I get some cords showing in the top left corner of the screen.

vector3df position = camera->getPosition();

That position for example
Programming Blog: http://www.uberwolf.com
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The middle value of 3d vector is called y, not z. You can compare elements of vectors just as you compare vectors by using '=='.
Use core::stringw(number) to create strings from numbers, and combine the numbers to a complete string. Then use .c _str() when passing it to a CGUIStaticText.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

well, to compare just a single axis compare the single axis:

Code: Select all

if (wall_1.Y == position.Y)
but I think this wont work this way, how great is the possibility that you get exactly at this point with float or even double values ?!?!?!? :shock: it's nearly zero !!! :lol:
better this way:

Code: Select all

if (wall_1.Y >= position.Y)
or in your case it should be:

Code: Select all

if (position.Y >= wall_1.Y)
You are now about 4 month working with Irrlicht and still don't know such elementary coding stuff ??? :lol: shame on you :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
webnoob
Posts: 17
Joined: Mon Aug 20, 2007 9:28 pm

Post by webnoob »

Just a little bit off topic, but still some good general advice.

Learn at least some basic coding techniques. I am very new to C++, in fact I have merely printed something to a screen before starting on Irrlicht (3 days ago), but my experience in other languages gives me the grasp on what I want to do, I just need to learn the syntax.

Find some basic programming tutorials and start experimenting more than you are, that way people will be more inclined to help you as they know that you are trying, which seems more that you are doing now.

WebNoob
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

I understand A wide range of the C++ language more than you. But this is my first API so meh.
Programming Blog: http://www.uberwolf.com
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Not really 4 months, i have been registered a while but I only use this sometimes on weekends so :{
Programming Blog: http://www.uberwolf.com
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

I am getting their but this is not working it compiles but it does not work

Code: Select all

   scene::ISceneNode* camera = smgr->addCameraSceneNodeFPS();
   
   if (camera)
   {
            camera->setPosition(vector3df(0,150,-100));
            camera->setRotation(vector3df(0,90,0));
            vector3df position = camera->getPosition();
          
                        
        
   }
   
 vector3df position = camera->getPosition();
 vector3df wall_1 = vector3df (100,100,100);
  


	


	int lastFPS = -1;

	while(device->run())
	if (device->isWindowActive())
	{
          if (position.Z >=wall_1.Z )
          {
            camera->setPosition(vector3df(0,100,0));           
                       }                       





IS their a way to set .Z postion etc?
Programming Blog: http://www.uberwolf.com
Post Reply