About Store Forum Documentation Contact



Post Reply 
Character went out from a car
Author Message
Harry Offline
Member

Post: #1
Character went out from a car
http://www.przeklej.pl/plik/car-avi-0007hh2bk

I have this error. Enter and exit to car is made by inCar bool variable. I change value of this variable only in two places. I debbug them but I didn't found anything. In physics.draw() I saw only one thing. This error shows only in some borders between two heightmap Areas. I tried to delete them and add new Areas but it doesn't help. Do you know why I have this?
(This post was last modified: 01-12-2010 10:18 PM by Harry.)
01-12-2010 10:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Character went out from a car
could you explain what exactly is the error?
what happens at 0:57 in the video?
did you press something?
01-12-2010 10:28 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #3
RE: Character went out from a car
No I only drive and suddenly character show on the screen and exit the car but I can't steering him. Debuging shows me nothing in part of code which responsible for exit.
(This post was last modified: 01-12-2010 10:32 PM by Harry.)
01-12-2010 10:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Character went out from a car
what happened to the car?
01-12-2010 10:48 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Character went out from a car
do you have only 1 player on the map?
and it's not constant or embedded or something?

maybe when you're travelling, another player gets loaded on the map, and camera jumps to him?
01-12-2010 10:48 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #6
RE: Character went out from a car
Yes I have only one object with Player type. It's set to Default. The car goes on until stopped. So my inCar bool (which when is on false makes that player exit the car) is still set on true, because when inCar is set to false care brakes should stop him immedietely:


if(active && inCar)
{
...
}else
{
wheel[0].brake(1500);wheel[1].brake(1500);
}
01-12-2010 11:26 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Character went out from a car
what's "active"?
where are you setting the player position when he's in the car?
01-12-2010 11:34 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #8
RE: Character went out from a car
It's a bool variable:

Bool InCar(){return active;}; // check if player is in car
void InCar(Bool b){active=b;}; // activate/deactivate the car

I use it in Game.cpp

if(Kb.bp(KB_ENTER) && carB)
{
Players[0].ctrl.actor.active(false);
inCar=true;
policeCars[whichCar].InCar(true);
}else carB=false;

carB is set on true if I know near which car I stay (integer whichCar variable);

I set position when I set the camera:
if(Camer == 1)
{
... // code which set camera behind car
if(inCar)Players[0].pos(policeCars[whichCar].pos()-Vec(0,-4,0));
else Players[0].pos((policeCars[whichCar].Pos()+Vec(2,0,0)));
}
01-13-2010 10:31 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Character went out from a car
you can't use this policeCars[whichCar]
you must use Reference (please check tutorial in game basics with references)
01-13-2010 06:25 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #10
RE: Character went out from a car
I made this:

Code:
struct Player => Reference<policeCar>refCar;
Player.cpp

if(!carB)
{
REPA(policeCars)
{
if(Dist(policeCars[i].actor.pos(),Players[0].ctrl.actor.pos())<=3)
{
whichCar=i;
refCar=policeCars[whichCar];
carB=true;
}
}
}
and then instead of write policeCars[whichCar] i use refCar(). ...

Is it ok? If yes problem still exist.
(This post was last modified: 01-13-2010 08:44 PM by Harry.)
01-13-2010 08:44 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Character went out from a car
make sure that you've removed whichCar completely
01-13-2010 10:08 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #12
RE: Character went out from a car
Ok I remove whichCar everywhere and now I have this part:

REPA(policeCars)
{ if(Dist(policeCars[i].actor.pos(),Players[0].ctrl.actor.pos())<=3)
{
refCar=policeCars[i];
carB=true;
}
}

But I'm not sure that it's ok, cause I still have a problem.
01-13-2010 11:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
RE: Character went out from a car
whats your current code for setting player position
check if its always being called
01-13-2010 11:18 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #14
RE: Character went out from a car
else if(Camer == 1)
{
if(inCar)Players[0].pos(Players[0].refCar().matrix().pos-Vec(0,-4,0));
else Players[0].pos((Players[0].refCar().matrixScaled().pos+Vec(2,0,0)));
}

I saw that suddenly on this Area this part after else is working and inCar i set to false, but I don't know why.
I set inCar to false only in two times:
I
policeCar::policeCar()
{
inCar=false;
II
if(inCar)
{
if(Kb.bp(KB_ENTER) && whichBrand==1)
{
inCar=false;

But when I'm debugging these parts of code isn't do.
01-13-2010 11:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #15
RE: Character went out from a car
Could the problem be because I have some lines in wrong order or I put __super:: in wrong place? What exactly this __super:: option is?
01-21-2010 05:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply