About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Actor.sweep, hit a plane
Author Message
RedcrowProd Offline
Bronze Supporter

Post: #1
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
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
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
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Bronze Supporter

Post: #3
RE: Actor.sweep, hit a plane
Oh, yes you are perfectly right, this is working fine now with (0,-0.1,0).

smile thanks for the help
03-24-2017 02:48 AM
Find all posts by this user Quote this message in a reply
Post Reply