Fullscreen Object Placement Problems

Posted By: Valdsator

Fullscreen Object Placement Problems - 03/14/11 21:29

I have an entity that is attached to a vertex of another moving entity (a gun in player's hand). This is the simple code I use to keep the gun in place.
Code:
my.x = ptemp.x;
my.y = ptemp.y;
my.z = ptemp.z;


Ptemp is obviously a vector which keeps that specific vertex's position. The problem is, though, that in fullscreen the framerate of the game is lower, and the gun begins falling behind the player when he moves. All of a sudden the gun is behind the player's hand instead of in the place they should be.

What should I do to make it so the gun keeps up with the vertex? In windowed mode it's perfect.
Posted By: Uhrwerk

Re: Fullscreen Object Placement Problems - 03/14/11 21:35

You should read the FAQs, Section "Bad timing, again":

http://manual.3dgamestudio.net/afaq.htm
Posted By: hopfel

Re: Fullscreen Object Placement Problems - 03/14/11 21:36

Too late -.-
You should set the position of the gun in the same frame you set the Positions of the player. For the fastest way you should write this three lines directly in your playerfunction under the animations or playermoves.
Posted By: Valdsator

Re: Fullscreen Object Placement Problems - 03/14/11 22:17

Awesome, that worked. I'll also make sure to look at the FAQ next time.

But, one last problem. In windowed mode, the gun can't shoot through walls if clipping through them, but in fullscreen it can shoot through walls if the player entity is facing a very specific angle. This doesn't appear to be a problem with timing, as I have just tried to make the player entity create the bullets instead of the gun entity, but it results in the same thing. It has something to do with the position of the gun, because if I use the player's position for the ent_create, it doesn't clip through.

Anyone know what the problem might be?
Posted By: Uhrwerk

Re: Fullscreen Object Placement Problems - 03/14/11 22:37

Well, according to your description the bullet is either created inside the weapon and or player or outside and depending on the angle its the other way around. You should create the bullet at the front of the weapon, so it does not intersect with any other collision hulls, when it is created. Additionally the flags set in the c_move command in the bullet's action play a role for this.
Posted By: Valdsator

Re: Fullscreen Object Placement Problems - 03/16/11 02:09

Well, I played around with some flags on the c_move, tried to move the bullet in front of the gun, and tried slowing it down, but it does the same thing. I don't really understand what the framerate of the game might change about collision. I guess the bullet can't tell fast enough it's being spawned in a wall, so it continues moving, and once it checks to see if it's colliding with a block, it's too late.

Not sure how I could fix this. Here is the code I have.
Code:
action pbullet(){
	c_setminmax(me);
	set(my,BRIGHT);
	my.emask = ENABLE_BLOCK|ENABLE_ENTITY;
	my.event = pbulletdelete;
	var panrandom = integer(random(11));
	my.pan = you.pan - 5 + panrandom;
	while(1){
	c_move(me,vector(50 * time_step,0,0),nullvector,GLIDE|IGNORE_PASSABLE|IGNORE_YOU);
	wait(1);
	}
}

action pgun(){
	weapon = me;
	var cooldown = 5;
	var pistolsnd;
	set(my,PASSABLE);
	while(1){
		cooldown += 1 * time_step;
		if(key_j){
			if(cooldown >= 4){
				you = ent_create("bullet1.mdl",vector(my.x,my.y,my.z),pbullet);
				if(snd_playing(pistolsnd)){
					snd_stop(pistolsnd);
				}
				pistolsnd = snd_play(pistol,100,0);
				cooldown = 0;
			}
		}
	wait(1);
	}
}


I guess I could just scrap this code and not make the bullet a moving entity, but I think this problem could appear with many other things, so I want to learn how to fix it.

Thanks for the suggestions, by the way.
Posted By: Redeemer

Re: Fullscreen Object Placement Problems - 03/16/11 13:21

I wouldn't suggest you make the bullet a moving entity. The bullet is moving through the wall because the spawn vector is inside the collision hull of the wall.

To fix this, you just need to move the spawn vector back away from the wall a bit.
© 2024 lite-C Forums