Jump to content

SetVelocity() on a Character Controller Crashes Game


Recommended Posts

Using SetVelocity() on a character controller crashes the game.

Is this function not supposed to work with character controllers?

 

example:

 

Using

 

self.entity:SetVelocity(Vec3(0),true)

 

or

 

local v=self.entity:GetVelocity(true)

self.entity:SetVelocity(v,true)

 

will crash the game when used on character controllers.

Link to comment
Share on other sites

Just made little tests, but I encountered no problem with self.entity:SetVelocity(Vec3(0),true) on character controller... Maybe something else wrong...

I tested on no beta, 4.1

 

in which function did you place the phrase ?

I placed it in the UpdateWorld() function. With it in my game crashes but if I comment it out my game is totally fine. I was trying to use it to prevent my character from falling through the terrain like this -

 

local pos=self.entity:GetPosition(true)

local height=terrain:GetElevation(pos.x,pos.z)

 

if pos.y<height then

self.entity:SetPosition(pos.x,height,pos.z)

local v=self.entity:GetVelocity(true)

self.entity:SetVelocity(Vec3(v.x,0,v.z),true)

end

 

but you are using 4.1? I am using 4.2 so maybe this is another new issue.

Link to comment
Share on other sites

You could set character vertical position a little bit higher that "height", this will prevent you falling down.

 

Keep in mind that SetPosition break physic calculation and allow an entity to be positionated everywhere without physic support.

 

You should move you character only using physic functions:

 

http://www.leadwerks.com/werkspace/page/api-reference/_/entity/

 

under "Physics"

I'm not english, so please sorry for my grammatical errors :)

 

I'm using Leadwerks and can programm in C++ and LUA

Link to comment
Share on other sites

You could set character vertical position a little bit higher that "height", this will prevent you falling down.

 

I've tried this.

 

I am making a game where the player jumps off mountains so there are times when they fall through the terrain and their Y velocity is like -150 so when they are placed back on/above the terrain they just fall through the terrain again.

 

I need to set the Y velocity to 0 without stopping the characters forward movement.

 

Also it creates notable flickering when I place the character above the terrain making the game very unpleasant to look at.

 

Keep in mind that SetPosition break physic calculation and allow an entity to be positionated everywhere without physic support.

 

You should move you character only using physic functions:

 

http://www.leadwerks.com/werkspace/page/api-reference/_/entity/

 

under "Physics"

 

SetPosition() works fine without using SetVelocity as stated earlier. I am using it to correct the broken physics so I know that it works without physics support.

 

SetVelocity() is under "Physics" and it isn't working! (that's what this bug report is all about)

 

Also most of the commands to move a character are actually under "Navigation"

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...