RedcrowProd
Member
|
Actor.sweep, hit a plane
Hey,
here is what i try to do:
Player attacks; if weapon ( like knife ) hit the floor, draw a decal at the location hit.
Following the game basics - "17 - small overlays" tutorial
Code:
PhysHit phys_hit;
if(Actor.sweep(Actor.pos(), &phys_hit))
{
if(phys_hit.group==AG_TERRAIN)
{
Game.World.terrainAddDecal(WHITE, bullet_mtrl_id, Matrix().setPosDir(phys_hit.plane.pos, phys_hit.plane.normal).scaleOrn(0.05));
}
}
This code works fine for the collision ( detect at the right time, when touched the floor ) but the issue is the plan pos are at the wrong location.
attached screenshot :
https://gyazo.com/3a5ae6c5b4d5eef5d28a0abac519a8b5
sooo here my questions : is it better to create a fake ray of the lenght of the weapon ?
am i doing something wrong ? or is there another way ?
thanks
(This post was last modified: 03-23-2017 05:36 AM by RedcrowProd.)
|
|
03-23-2017 05:31 AM |
|
Esenthel
Administrator
|
RE: Actor.sweep, hit a plane
Hi,
I don't know what is what on the screenshot.
Perhaps the knife weapon actor sweep detects another actor first, and not the ground?
Can you provide a small physics based project that reproduces this issue and I would check what's wrong?
Edit:
forget what I said, I see that your code is wrong.
You pass a wrong parameter to the 'sweep' function, you specify the movement vector as the position?
you should pass the delta movement, something like (0,-0.1,0) or something, you could make it velocity or time dependent.
|
|
03-23-2017 09:41 PM |
|
RedcrowProd
Member
|
RE: Actor.sweep, hit a plane
Oh, yes you are perfectly right, this is working fine now with (0,-0.1,0).
thanks for the help
|
|
03-24-2017 02:48 AM |
|