fenomas Posted September 19, 2017 Share Posted September 19, 2017 6 hours ago, MackeyK24 said: Shit... I don't even wanna use physics to move my character .. Well, you fundamentally have two choices in managing the positions of things in a scene. Either you run everything, or you let the physics engine run things. They're completely different ways to work, and you have to figure out which one you want. If you run things, that means you're the one who knows every object's correct position. If your'e doing something where the character just runs and jumps around an endless plane, then you don't need a physics engine - just set the character's Y to zero at all times unless he's jumping, and move him around by changing the X/Z positions, etc. On the other hand, if your scene has obstructions or inclines or whatever, and you can't easily calculate how the character's position should change depending on which direction the player moves, then you probably want to tell the physics engine what constraints exist and let the engine decide what the correct positions for things are. But what you generally don't want to do is double-dip, and sort of use the engine to do this or that but also manually set the positions yourself based on some raycasting in certain situations, etc. 6 hours ago, MackeyK24 said: Do know of a good way to detect "IS GROUNDED" ? Cannon tracks collisions as "contacts" between one body and another. The world object has an array of contacts, which one can look through to check if two bodies are touching, and you can also add event listeners to the world object for "beginContact", "endContact", and so on. Afraid I don't have any sample code handy for this, and I don't know if Babylon exposes any useful helpers that wrap whatever Cannon expects you to do. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 19, 2017 Share Posted September 19, 2017 yall are tripping, setting the mass to 0 does not get rid of collision events, it just makes it "static" which does not mean you cant not affect it with your own calculations... I have posted physics controllers that use this method and have proven it to work so..... Im out of this conversation though then if that's the reaction people are having... way to not listen to the person who has deployed this in a production product before though. player_box.body.collisionResponse = 0; player_box.body.addEventListener("collide", function(e){ player_box.body.grounded = true; player_box.body.collisionResponse = 1; }); scene.registerBeforeRender(function(){ //console.log(player_box.position); if(player_box.body.collisionResponse){ player_box.body.grounded = true; player_box.body.velocity.y = 0; }else{ player_box.body.grounded = false; } if(player_box.body.grounded || gravity.y == 0){ if(keys.w){ if(player.speed.f < settings.speeds.normal.f){ player.speed.f += settings.accel; }else{ player.speed.f = settings.speeds.normal.f; } }else if(keys.s){ if(player.speed.f > settings.speeds.normal.b){ player.speed.f -= settings.accel; }else{ player.speed.f = settings.speeds.normal.b; } } if(keys.a){ if(player.speed.s > settings.speeds.normal.s*-1){ player.speed.s -= settings.accel; }else{ player.speed.s = settings.speeds.normal.s*-1; } } if(keys.d ){ if(player.speed.s < settings.speeds.normal.s){ player.speed.s += settings.accel; }else{ player.speed.s = settings.speeds.normal.s; } } if(keys.space){ if(gravity.y != 0 && player_box.body.grounded){ player_box.body.collisionResponse = 0; var jumpVector = v3(0,6.5,0); player_box.applyImpulse(jumpVector, player_box.position); }else{ if(player.speed.u < -2){ player.speed.u -= settings.accel; }else{ player.speed.u = -2; } } } ... Is a cheep way to do grounding yet it does not work in all instances (also gravity is enabled)... but this might give you an idea. Its not a final example at all due to it not taking side collisions into account. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 1 hour ago, Pryme8 said: Im out of this conversation though then if that's the reaction people are having... way to not listen to the person who has deployed this in a production product before though. Hey @Pryme8 Dont bail... I don't know all these things and I VALUE everyone's opinion of the matters a post... I am just trying to come with an optimum 'Character Controller' for the toolkit... So everybody has the same basic 'Controller' type functions to use mot move around your character like unity does... They have a "Magic" grounded flag they use on there character controller that they move around WITHOUT physics... I tried use just Positions movement (No physics) using BOTH 1... Just Plain Ole Translation (but like you said have to DO EVERYTHING manually) and 2... MoveWithCollisions works but can't tell when grounded... no kind of collision event (would either have to recast or check mesh.intersections) Then with physics... has great collision detection and I can move the guy around... I was just WORRIED about having to TAG everything in the world I want to interact with or jump on to ALSO have Physics State... Would that just EAT up all resources doing EVERYTHING with physics and adding physics state to too much. And my biggest problem... I can't get to move the "Correct" forward movement (Diagonal movement really)... That is where ALL those 'MacGuyver' shit I am trying to do with physics now... Because I MUST be doing something wrong to move... Not I tried imposter.ApplyForce but does not seems to DO ANYTHING... The only way I got the got to move around AT ALL... was either Moving the position myself (which cannon says is ok on Type.DYNAMIC) or call setLinearVelocity and setAngularVelocity... Move diagonal movement is SHITTY from the standard velocity move vector I use (as if I was gonna mesh.MoveWithCollision) It sounds like, from all the back and forth... I am ultimately going to need to use Physics for base Toolkit 'Character Controller' so it can interact with inclines and terrain and other NON-STATIC items... SO I AM REALLY GOING TO FIX MY MOVEMENT ISSUES: Yo @fenomas and @Pryme8 can you please take a QUICK look at this video and see if you can tell WHAT THE HECK I am doing wrong: http://mackey.cloud/files/videos/U3Dmoving.mp4 As always I Appreciate and REALLY VALUES EVERYONES INPUT... So KEEP EM COMING Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 19, 2017 Share Posted September 19, 2017 how are you calculating your forward vector? are you taking position from origin into account? Tell you what, when I get home today Ill watch your video and help out. I prolly already have a solution for you that you can adapt. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 6 minutes ago, Pryme8 said: how are you calculating your forward vector? are you taking position from origin into account? Tell you what, when I get home today Ill watch your video and help out. I prolly already have a solution for you that you can adapt. SWEET... Cant wait till you get home then 6 minutes ago, Pryme8 said: how are you calculating your forward vector? are you taking position from origin into account? Tell you what, when I get home today Ill watch your video and help out. I prolly already have a solution for you that you can adapt. I don't think... I am calculating using X and Z input for device "Transforming To World" and normalizing greater than 1 and I WOULD normally use THAT move vector and pass that to mesh.MoveWithCollisions(velocity). I tried to take that SAME velocity vector and feed to to setLinearVelocity ... THAT IS WHERE IS GOES WRONG... iT MUST be something else involved when using a move vector using positions rather than physics velocity.... An NO I don't take into account my current position... here is my 'user input' code: The 'after' function job is to calculate the: 1... Movement Vector based on Horizontal and Vertical input from user. 2... Rotation Angle based on Mouse X Movement 3... When we JUMPED in that frame protected after():void { this.jumpingFrame = false; this.rotationAngle = 0.0; if (this.character == null) return; this._isCharacterJumping = this.character.isJumping(); this._isCharacterFalling = this.character.isFalling(); this._isCharacterGrounded = this.character.isGrounded(); // Setup User Input Axis if (this.enableInput === false) return; this.wheelInput = this.manager.getUserInput(BABYLON.UserInputAxis.Wheel); this.mouseXInput = this.manager.getUserInput(BABYLON.UserInputAxis.MouseX); this.mouseYInput = this.manager.getUserInput(BABYLON.UserInputAxis.MouseY); this.verticalInput = this.manager.getUserInput(BABYLON.UserInputAxis.Vertical); this.horizontalInput = this.manager.getUserInput(BABYLON.UserInputAxis.Horizontal); // Pseudo normalize dead zone input values var deadZone:number = BABYLON.UserInputOptions.GamepadDeadStickValue; if (this.horizontalInput >= -deadZone && this.horizontalInput <= deadZone) this.horizontalInput = 0.0; if (this.verticalInput >= -deadZone && this.verticalInput <= deadZone) this.verticalInput = 0.0; // Pseudo normalize horizontal input values if (this.horizontalInput > 0.5) this.horizontalInput = 1.0; else if (this.horizontalInput < -0.5) this.horizontalInput = -1.0; else if (this.horizontalInput > 0.1) this.horizontalInput = 0.5; else if (this.horizontalInput < -0.1) this.horizontalInput = -0.5; // Pseudo normalize vertical input values if (this.verticalInput > 0.5) this.verticalInput = 1.0; else if (this.verticalInput < -0.5) this.verticalInput = -1.0; else if (this.verticalInput > 0.1) this.verticalInput = 0.5; else if (this.verticalInput < -0.1) this.verticalInput = -0.5; // Apply User Input Movement Properties var deltaTime:number = this.manager.deltaTime; if (this._isCharacterGrounded === true) { this.movementVector.x = this.horizontalInput; this.movementVector.z = this.verticalInput; this.manager.transformDirectionToRef(this.mesh, this.movementVector, this.movementVector); if (this.movementVector.length() > 1.0) BABYLON.Vector3.NormalizeToRef(this.movementVector, this.movementVector); this.movementVector.scaleInPlace(this.speed() * BABYLON.ThirdPersonFactors.Movement); } if (this.autoTurning === true) { this.rotationAngle = (this.mouseXInput * this.turnSpeed * BABYLON.ThirdPersonFactors.Rotation); } if (this._isCharacterGrounded === true) { this.jumpingFrame = (this.manager.getKeyInput(this.keyboardJump) || this.manager.getButtonInput(this.buttonJump)); } } Then my update function applies the movement: protected update() :void { // Update character movements if (this.character != null) { var jump:number = ((this.jumpingFrame === true) ? this.jumpSpeed * BABYLON.ThirdPersonFactors.Jumping : 0.0); this.character.move(this.movementVector, this.rotationAngle, jump, this.manager.deltaTime); } // Update character animations if (this.animator != null) { this.animator.setFloat("Foward", this.verticalInput); this.animator.setFloat("Strafe", this.horizontalInput); this.animator.setBool("isJumping", this._isCharacterJumping); this.animator.setBool("isFalling", this._isCharacterFalling); this.animator.setBool("isGrounded", this._isCharacterGrounded); } } The character Move function calls move set Linear and angular velocity with "Move Vector" and "Rotation Angle" Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 19, 2017 Share Posted September 19, 2017 var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y = 0;var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; var move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); player_box.body.velocity.x = move.x; player_box.body.velocity.z = move.z; player_box.body.velocity.y = move.y; Hope some of this helps. Spankied 1 Quote Link to comment Share on other sites More sharing options...
Aerion Posted September 19, 2017 Share Posted September 19, 2017 Any luck @MackeyK24 ? <3 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 1 hour ago, Pryme8 said: var move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); I don't get that part... But I think your saying my move vector NEEDS to relative to the camera FOWARD AND RIGHT... Not sure WHY Up Vector plays a part though... But I will play/look around for code dealing with adjusting the move vector relative to camera BTW... I decided to take @fenomas advise and just let physics do everything (I will come back later and try apply custom gravity or adding some impulse to top of jump to give a slight hover before falling back down)... My move vector is the only fucked up right now (but I will look into camera offset)... So here is my 'Character Controller' class (like Unity Character Controller)... But real CLEAN using physics engine: module BABYLON { export class CharacterController extends BABYLON.MeshComponent { public avatarHeight:number = 2.0; public avatarRadius:number = 0.25; public fallingVelocity:number = 0.1; public isJumping():boolean { return this._jumping; } public isFalling():boolean { return this._falling; } public isGrounded():boolean { return this._grounded; } public getVelocity():BABYLON.Vector3 { return this.manager.getLinearVelocity(this.mesh); } private _jumping:boolean = false; private _falling:boolean = false; private _grounded:boolean = true; private _threashold:number = 0.5; private _linearVelocity:BABYLON.Vector3 = BABYLON.Vector3.Zero(); private _angularVelocity:BABYLON.Vector3 = BABYLON.Vector3.Zero(); private _jumpingVelocity:BABYLON.Vector3 = BABYLON.Vector3.Zero(); public constructor(owner: BABYLON.AbstractMesh, scene: BABYLON.Scene, tick: boolean = true, propertyBag: any = {}) { super(owner, scene, tick, propertyBag); this.avatarHeight = this.getProperty("avatarHeight", 2.0); this.avatarRadius = this.getProperty("avatarRadius", 0.25); this.fallingVelocity = this.getProperty("fallingVelocity", 0.1); } protected start():void { this._jumping = false; this._falling = false; this._grounded = true; this.updateGroundingState(); this.onCollisionEvent((collider:BABYLON.AbstractMesh, tag:string) => { if (this.manager.checkCollisionContact(this.mesh, collider, BABYLON.CollisionContact.Bottom, this._threashold) === true) { this._jumping = false; this.updateGroundingState(); } }); } protected update() :void { this.updateGroundingState(); } public move(velocity:BABYLON.Vector3, rotation:number = 0.0, jump:number = 0.0):void { this._linearVelocity.copyFromFloats(velocity.x, 0.0, velocity.z); this._angularVelocity.copyFromFloats(0.0, rotation, 0.0); if (jump > 0.0) { this._jumping = true; this._jumpingVelocity.copyFromFloats(0.0, jump, 0.0); this.manager.applyImpulse(this.mesh, this._jumpingVelocity, this.mesh.getAbsolutePosition()); this.updateGroundingState(); } this.manager.setAngularVelocity(this.mesh, this._angularVelocity); this.manager.setLinearVelocity(this.mesh, this._linearVelocity); } public rotate(x: number, y: number, z: number):void { this._angularVelocity.copyFromFloats(x, y, z); this.manager.setAngularVelocity(this.mesh, this._angularVelocity); } private updateGroundingState():void { var velocity:BABYLON.Vector3 = this.getVelocity(); this._falling = (velocity != null && velocity.y < (-this.fallingVelocity)); this._grounded = (this._jumping === false && this._falling === false); } } } That way its NOT cannon specific... the manager just WRAPS the imposter.applyImpulse and setLinearVelocity/setAngularVelocity so I can also HANDLE any difference in the engine there to but still be to just say : manager.applyImpulse from anywhere in code. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 10 minutes ago, Mythros said: Any luck @MackeyK24 ? <3 Still working on it Quote Link to comment Share on other sites More sharing options...
fenomas Posted September 19, 2017 Share Posted September 19, 2017 3 hours ago, Pryme8 said: yall are tripping, setting the mass to 0 does not get rid of collision events, it just makes it "static" which does not mean you cant not affect it with your own calculations... That's cool and all, but the question was how to disable gravity 1 hour ago, MackeyK24 said: Yo @fenomas and @Pryme8 can you please take a QUICK look at this video and see if you can tell WHAT THE HECK I am doing wrong: http://mackey.cloud/files/videos/U3Dmoving.mp4 Err, nothing looked wrong to me, but it's pretty hard to look at code in a video and figure out where the bug is, and I'm not sure I was looking in the right place. Instead, I whipped up a simple demo of the "naive" version of movement that I outlined in my first reply. It moves the camera with a player body, applies the right kind of movement vector, detects ground contacts, and so on. All these things can be done in other ways as well, but perhaps it will help as a start. http://www.babylonjs-playground.com/#U4F9K1 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 23 minutes ago, fenomas said: That's cool and all, but the question was how to disable gravity Err, nothing looked wrong to me, but it's pretty hard to look at code in a video and figure out where the bug is, and I'm not sure I was looking in the right place. Instead, I whipped up a simple demo of the "naive" version of movement that I outlined in my first reply. It moves the camera with a player body, applies the right kind of movement vector, detects ground contacts, and so on. All these things can be done in other ways as well, but perhaps it will help as a start. http://www.babylonjs-playground.com/#U4F9K1 Sweet.. I will look at.... Quick question.... What do you normally set for the mass of a humanoid character... I been just setting that to 1... What is Mass... Kilograms or something... That could have a lot to do with the jumping huh ??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 27 minutes ago, fenomas said: That's cool and all, but the question was how to disable gravity Err, nothing looked wrong to me, but it's pretty hard to look at code in a video and figure out where the bug is, and I'm not sure I was looking in the right place. Instead, I whipped up a simple demo of the "naive" version of movement that I outlined in my first reply. It moves the camera with a player body, applies the right kind of movement vector, detects ground contacts, and so on. All these things can be done in other ways as well, but perhaps it will help as a start. http://www.babylonjs-playground.com/#U4F9K1 Shit man... I had another post about RotateTowards function... I was trying to Add the rotation to move vector to get the movement exactly going the way: I was trying something like this: var transformForward:BABYLON.Vector3 = BABYLON.Vector3.Forward(); transformForward.scaleInPlace(this.verticalInput); var transformRight:BABYLON.Vector3 = BABYLON.Vector3.Right(); transformRight.scaleInPlace(this.horizontalInput); var targetDirection:BABYLON.Vector3 = transformForward.add(transformRight); this.moveDirection = Vector3.RotateTowards(this.moveDirection, targetDirection, 200 * BABYLON.Constants.Deg2Rad * deltaTime, 1000); So I can adjust the 'MoveDirection' with a bit of rotation in it... But it looks like you are doing that with this: var rot = player.getWorldMatrix().getRotationMatrix() var vec = new BABYLON.Vector3(xdir, 0, zdir).normalize().scaleInPlace(speed) BABYLON.Vector3.TransformCoordinatesToRef(vec, rot, vec) So it looks like the Character's current rotation is "Transformed" into the horizontal and vertical input movement vector... Then I should be able to setLinearVelocity with that... Still don't wanna use 'ApplyForce' because I want the movement exactly controllable for character movement synced with animations... But shit man... That might have been my main fucking problem right there... I gotta check Note: I still gotta ROTATE the character to actually turn... this just set the CORRECT move vector for the SetLinearVelocity or ApplyForce calls ??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 Yo @fenomas ... I found an article bout this: for (var i = 0; i < contacts.length; i++) { var bi = contacts[i].bi var bj = contacts[i].bj if (pbody === bi || pbody === bj) { if (gbody === bi || gbody === bj) { onground = true break } } } But it looks like they ALSO check the contact normal for a certain threshold... Is that what I should be doing as well: var canJump = false; var contactNormal = new CANNON.Vec3(); // Normal in the contact, pointing *out* of whatever the player touched var upAxis = new CANNON.Vec3(0,1,0); cannonBody.addEventListener("collide",function(e){ var contact = e.contact; // contact.bi and contact.bj are the colliding bodies, and contact.ni is the collision normal. // We do not yet know which one is which! Let's check. if(contact.bi.id == cannonBody.id) // bi is the player body, flip the contact normal contact.ni.negate(contactNormal); else contactNormal.copy(contact.ni); // bi is something else. Keep the normal as it is // If contactNormal.dot(upAxis) is between 0 and 1, we know that the contact normal is somewhat in the up direction. if(contactNormal.dot(upAxis) > 0.5) // Use a "good" threshold value between 0 and 1 here! canJump = true; }); That is what I was basing my : manager.checkCollisionContact function to do base of the above code Pryme8 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 Man with all this physics... I can't wait to try the new Energy.JS Physics Engine coming out Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 31 minutes ago, MackeyK24 said: So it looks like the Character's current rotation is "Transformed" into the horizontal and vertical input movement vector... Then I should be able to setLinearVelocity with that... Still don't wanna use 'ApplyForce' because I want the movement exactly controllable for character movement synced with animations... But shit man... That might have been my main fucking problem right there... I gotta check Shit... Still did NOT work... It is a little better but still does NOT move exactly at where I am pointing like in video... Going to try to make relative to camera next... Ill be back Quote Link to comment Share on other sites More sharing options...
adam Posted September 19, 2017 Share Posted September 19, 2017 4 hours ago, Pryme8 said: way to not listen to the person who has deployed this in a production product before though. wow ... Quote Link to comment Share on other sites More sharing options...
adam Posted September 19, 2017 Share Posted September 19, 2017 4 hours ago, Pryme8 said: yall are tripping, setting the mass to 0 does not get rid of collision events, it just makes it "static" which does not mean you cant not affect it with your own calculations... What happens when you run into another static body? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 Hey @adam how it going bro... Man I am going to give it one LAST shot and try to figure out @Pryme8 code : var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y = 0; var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; var move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); If I can't get that ... SCREW IT... I am tired of messing with this part of the Toolkit... I am just going to move my imposter X and Z around manually (which I want that precise control as setLinearVelocity would give)... And let the physics do everything else... But heck man just gonna go with this: mesh.position.addInPlace(moveVelocity) and move on. Its only my "Pre-Built Character Controller" if folks don't wanna use my Controller... that fine... the whole toolkit is designed for folks to make there own script components and attach to game objects...Folks can make what ever other controller they see fit. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 19, 2017 Share Posted September 19, 2017 2 hours ago, adam said: What happens when you run into another static body? Not sure, never tested that! good question though... I'm pretty sure the collision event still fires though. Ill do a PG and test before I need to eat my words though. ANNND it does not... that's odd I figured the collision would still fire... hmmm y'all got me thinking now... This worked back when you constructed the impostors like : setPhysicsState(BABYLON.PhysicsImpostor.SphereImpostor, { mass: 0.0, friction: 0.0001, restitution: 0.0}); So now I need to do some research because I was under the impression the event would still fire it just would not have any responses, but alas that is not the case. Maybe it has something to do with using broadphase vs narrow? I have not looked at this in like over a year so I really dont remember off the top of my head, Id have to be back at the house looking at script. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 19, 2017 Author Share Posted September 19, 2017 Yo @Pryme8 ... I will just go with regular physics... not try to fight against the gravity... just let engine handle... Now I still gotta move X and Z but I am not sure about the code you gave for camera offset: var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y = 0; var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; var move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); What is f_speed and s_speed and u_speed If I can figure that part... I believe I can mesh.imposter.setLinearVelocity(move) and HOPEFULLY will move in right direction.... Did you get a chance to see my problem in video... When I point not quite to 45 degrees and move forward on keyboard I THinkmy problem lies in the PROPER move vector calculation but I can quite get what you doing above Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 19, 2017 Share Posted September 19, 2017 I have not gotten to get home yet, but I will peep it for sure tonight! Ive made a 1st/3rd person player controller for BJS before and the scripts on my work rig at home so I need to reference that. https://playground.babylonjs.com/#2ILRYY#6 Here is a cheep way to collide two mass 0 objects also (but its really kind of hacky and wont work in most situations)@MackeyK24m https://github.com/Pryme8/TERIABLE/blob/gh-pages/Infinity/teriable-infinity-0.0.1.js Has a really old school one I did, nothing like the new one but its what I used as my model.http://pryme8.github.io/TERIABLE/infinity.html Its really rudimentary but might get you in the correct direction (no pun intended), if doing the Demo id hold ctrl until you hit the ground or its kinda hard to get a bearing of where you are. Quote Link to comment Share on other sites More sharing options...
fenomas Posted September 20, 2017 Share Posted September 20, 2017 7 hours ago, MackeyK24 said: Quick question.... What do you normally set for the mass of a humanoid character... I been just setting that to 1... What is Mass... Kilograms or something... That could have a lot to do with the jumping huh ??? I usually start out with masses of 1 and tune from there. For the most part it doesn't make a huge amount of difference, you can just pick a value for the most important thing and scale other things relative to that. 7 hours ago, MackeyK24 said: But it looks like they ALSO check the contact normal for a certain threshold... Is that what I should be doing as well: Like I said, there are multiple ways to do most of this stuff. My sample code checked for any contact between the player and the ground. The sample code you posted checks for any contact on the player body with an upwards-pointing normal. The latter is probably what you want here, since then it will also work if the player is standing on other objects. If you want to find collisions between two specific things you want the former. 6 hours ago, MackeyK24 said: Shit... Still did NOT work... It is a little better but still does NOT move exactly at where I am pointing like in video... Going to try to make relative to camera next... Ill be back Why don't you copy the code you're using into the demo I posted, so we can help? I have no idea what's going on in the sample code you posted, because it basically just calls "Vector3.RotateTowards", and Babylon doesn't seem to have a function by that name. If you haven't used the playground before, you can just open my link, change the code, hit "Save", and then post the URL here, and we'll be able to see and fix what you've shared. 5 hours ago, MackeyK24 said: I am just going to move my imposter X and Z around manually (which I want that precise control as setLinearVelocity would give)... And let the physics do everything else... But heck man just gonna go with this: mesh.position.addInPlace(moveVelocity) and move on. Precise control is not what you want. If the player is facing towards a ramp, and you move them forward by some precise amount, you'll just be moving them inside the ramp. If you want the player to have complete control over their movement just set the player velocity. (But keep in mind that the results won't feel "physical" - e.g. the player will have no inertia; no matter how fast they're moving in one direction pressing the a button will make them instantly move at top speed in the other direction.) Quote Link to comment Share on other sites More sharing options...
fenomas Posted September 20, 2017 Share Posted September 20, 2017 5 hours ago, Pryme8 said: Not sure, never tested that! good question though... I'm pretty sure the collision event still fires though. Ill do a PG and test before I need to eat my words though. ANNND it does not... that's odd I figured the collision would still fire... hmmm y'all got me thinking now... This worked back when you constructed the impostors like : Setting a body mass to zero makes the body static, like a wall. The engine doesn't test for collisions between two walls! There would be a bunch of other problems as well - constraints would start working differently, any dynamic bodies the player collided with would bounce off as if the player had infinite mass, etc. The only reason to set a body's mass to zero is if you want the physics engine to treat it like a wall. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 20, 2017 Author Share Posted September 20, 2017 Yeah @fenomas The Physics Guru fenomas 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 20, 2017 Author Share Posted September 20, 2017 13 hours ago, fenomas said: Why don't you copy the code you're using into the demo I posted, so we can help? I have no idea what's going on in the sample code you posted, because it basically just calls "Vector3.RotateTowards", and Babylon doesn't seem to have a function by that name. HOLY SHIT... I FOUND THE PROBLEM... WAS SO FUCKING TINY... Started try to port all my code to your playground and then I saw it.... If moving via Zdir or Xdir ... FRICTION = 0 ELSE FRICTION = BASEFRICTION... I tried setting my player (which had a constant friction 0.1) to just ZERO (constant ZERO) and the MUTHER FUCKER (pleas excuse my language) MOVED PERFECTLY.... Such a Small thing like friction = 0.1 while moving fucks you up... I am gonna implement switching from the BaseFriction giving at design time back and forth to ZERO based on whether I am actually moving or not... But I think that it.... That took TWO WHOLE forum post pages to find that shit.... But FUCK... Its FOUND Pryme8 and HeadClot 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.