How do you use custom collision on a skeletal mesh in UE4?

I have a vehicle rig that is a skeletal mesh that imports fine in to unreal but I was wondering how to use a mesh for collision on it. Normally you can just name the collision mesh with UCX_ in front of the name to do it but with skeletal meshes it makes you use a system called phat and I only see cubes/spheres/capsules for collision with that.

Collision Detection without Coordinates in Tilemaps in Pygame

So if I wan’t to make a collision detection with rectangles, than I can just do this as I have the coordinates of the rectangle:

rcx = 200 rcy = 200 rcw = 200 rch = 100 plx = 500 ply = 450 plw = 50 plh = 50 rectcolor = (100, 150, 200)  testobj = pygame.draw.rect(win, rectcolor, (rcx, rcy, rcw, rch)) player = pygame.draw.rect(win, (150, 200, 100), (plx, ply, plw, plh))     if plx <= rcx + rcw and plx + plw >= rcx and ply <= rcy + rch and ply + plh >= rcy:     rectcolor = (50, 100, 50) else:     rectcolor = (100, 150, 200) 

Ok, good! I made a collision detection with rectangles because I know the coordinates of the rectangles. (I don’t think this is the most efficient way but it works) Anyways I am programming a Bomberman game, right now I don’t have any sprites but I use rectangles for it. This is my code:

import pygame  pygame.init()  WinWidth = 800 WinHeight = 608 p1x = 32 p1y = 32 vel = 1 clock = pygame.time.Clock()  win = pygame.display.set_mode((WinWidth, WinHeight))  def player():     pygame.draw.rect(win, (0, 200, 200), (p1x, p1y, 32, 32))  class invi:     def __init__(self, x, y):         self.x = x         self.y = y         pygame.draw.rect(win, (0, 255, 200), (x, y, 32, 32))   class Wall:     def __init__(self, x, y):         self.x = x         self.y = y         pygame.draw.rect(win, (50, 50, 50), (x, y, 32, 32))   class Breakable:     def __init__(self, x, y):         self.x = x         self.y = y         pygame.draw.rect(win, (200, 150, 100), (x, y, 32, 32))   game_map1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],              [0, 10, 10, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 10, 10, 0],              [0, 10, 0, 2, 0, 2, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 10, 0],              [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],              [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0],              [0, 2, 2, 2, 2, 10, 10, 2, 2, 10, 2, 2, 10, 10, 2, 2, 2, 2, 0],              [0, 2, 0, 2, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 2, 0, 2, 0],              [0, 2, 2, 2, 2, 2, 0, 2, 2, 10, 2, 2, 0, 2, 2, 2, 2, 2, 0],              [0, 2, 0, 2, 0, 2, 0, 2, 10, 10, 10, 2, 0, 2, 0, 2, 0, 2, 0],              [0, 0, 0, 2, 2, 10, 10, 10, 10, 10, 10, 10, 10, 10, 2, 2, 0, 0, 0],              [0, 2, 0, 2, 0, 2, 0, 2, 10, 10, 10, 2, 0, 2, 0, 2, 0, 2, 0],              [0, 2, 2, 2, 2, 2, 0, 2, 2, 10, 2, 2, 0, 2, 2, 2, 2, 2, 0],              [0, 2, 0, 2, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 2, 0, 2, 0],              [0, 2, 2, 2, 2, 10, 10, 2, 2, 10, 2, 2, 10, 10, 2, 2, 2, 2, 0],              [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0],              [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],              [0, 10, 0, 2, 0, 2, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 10, 0],              [0, 10, 10, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 10, 10, 0],              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]  run = True while run:      pygame.init()      clock.tick(100)     win.fill((0, 255, 200))     y = 0     for layer in game_map1:         x = 0         for tile in layer:             if tile == 0:                 Wall(x * 32, y * 32)             if tile == 10:                 invi(x * 32, y * 32)             if tile == 2:                 Breakable(x * 32, y * 32)             x += 1         y += 1      player()      for event in pygame.event.get():         if event.type == pygame.QUIT:             pygame.quit()             run = False     if event.type == pygame.KEYDOWN:         if event.key == pygame.K_d:             p1x += vel         elif event.key == pygame.K_a:             p1x -= vel      pygame.display.update() 

sooo… I watched a tutorial and even tried to make a collision detection on my own. But I just can’t do it. I don’t have coordinates for the rectangles in the tilemap and there are very much rectangles in the tilemap, too. How could you make a collision detection with a tilemap with no coordinates and many rectangles? And yeah, the game doesn’t have much stuff going un ’til now… oh and I deleted the parts where I tried to make a collision detection as they all were bad, didn’t work, took up much of the place and just made the whole code more confusing.

Btw if this is not a good question to ask in this StackExchange Q&A Website, sorry, im new to this Website. But I would still be happy to get an answer on this question! šŸ™‚

How to do collision detection in Unity between Character Controller, Rigidbody Collider and a NavmeshAgent?

I would like to know more about how collision detection works in Unity especially when character controllers and NavmeshAgents get involved.

For example, how can I detect collision between NavmeshAgent and a CharacterController? I have added a sphere collider to my NavmeshAgent, but it doesn’t seem to detect a collision unless I set it to “IsTrigger”. I have tried OnCollisionEnter(), OnControllerColliderHit() and OnTriggerEnter(). OnTriggerEnter() seems to be the only one that works and only when I enable “IsTrigger”.

How come the other two don’t work? Shouldn’t they? What if I didn’t want to make the collider a trigger?

Ray casting through terrain mesh + Octree ( Mesh collision )

I’m currently in development of a terrain editor which i will use for my game. One thing that is partially stopping my development is that I don’t have collision detection implemented between mouse ray cast and the terrain mesh.

The terrain is consisted of triangles and can be lowered and raised.Also the x and y values of the mesh don’t change. Of course what i need to do is ray cast through my mouse positions and get intersected triangle. I would get the point on the triangle using Barycentric coordinates. Just I’m not quite sure how does octree come into play here. As far as I understand it it works like a 3d quadtree, splitting the box into smaller box that the ray intersects. But which box do i choose ? How do i know which box is the closest one to the terrain, if either raised or lowered terrain ? How many subdivisions would i have? I was thinking on having as much as i have tiles( basically the last level of subdivisions would correspond to a x^3 box).

Right now i’m just doing collision with the 0 Z-value plane, and it works okay, but if the terrain is a bit raised then this can give faulty results.

Other two methods that i found is to iterate through the mesh, which of course is insanely inefficient; the other is to project the terrain in reverse and then i guess do some checking with the mouse coordinates (think it’s called z-buffer checking or something).

If anyone has any other ideas i’m all ears. Just note that the algorithm should be an efficient one (of course this depends on the implementation) and accurate.

Thanks !

Theoretical question about Zobrist hashing and chances of collision with slight modification

I’m using zobrist hashing, but for certain positions I want to put them in the cache but make them unique. This is what I’m doing:

quint64 hash = position.zobristHash(); if (makeItUnique)     hash ^= reinterpret_cast<quint64>(this); 

Is there any reason to suppose that what I’m doing will increase the likelihood of hash collisions?

Rolling on collision

I’m having a small issue where if I collide with another object (let’s use a simple cube) with my player (this player is just a sphere), the ball will infinitely roll in the opposite direction and WILL NOT STOP. my code is as follows:

using UnityEngine;  public class PlayerController : MonoBehaviour {     private Rigidbody rb;     private float moveHorizontal;     private float moveVertical;      public float moveSpeed;         // Start is called before the first frame update     private void Awake()     {         rb = GetComponent<Rigidbody>();     }      // Update is called once per frame     void Update()     {         moveHorizontal = Input.GetAxis("Horizontal");         moveVertical = Input.GetAxis("Vertical");     }      private void FixedUpdate()     {         MovePlayer();             }      private void MovePlayer()     {         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);         rb.AddForce(movement * moveSpeed);     } 

I even changed the ForceMode to ForceMode.Impulse so be able to see what it was doing a little easier, and it is in fact slowly rolling away infinitely with no way to stop it.

Both objects have a Rigidbody for them to be able to react to being hit. This is my first time messing with 3d. I tried to do something like this to make it not roll away on impact

private void OnCollisionExit(Collision collision)     {         if (collision.collider.gameObject.layer != LayerMask.NameToLayer("Ground"))         {             rb.velocity = Vector3.zero;         }     } 

But then if I want to jump on the cube (lets say the cube is an enemy and I’m jumping on it to kill it), then it acts very wonky each time it touches the edge of the cube and I haven’t made it on top (again, because the velocity is being set to zero). I am all out of ideas and would love some input here!

EDIT: I now realize that the ball will slowly roll forever even without collision and just simply moving. I am very lost !

Is there an algorithm to check if two spheres are in collision and whether they’re colliding on the x or the x axis?

I was wondering if there was a way to find out whether a spheres is intersecting another sphere on either its x or its z axis. For instance, Planet A is moving along the Z Axis towards Planet B a stationary object and when collision occurs I would like to get a reponse that tells me that they collided on the zAxis. I can find out if a collsion has occured using the code below however I’m not sure on how to impliment the directional aspect of this. Any help would be appreciated.

    enum ECol { x_Axis, z_Axis, none };      // Collision detection between two spheres      distanceX = sphere2XPosition - sphere1XPosition;     distanceZ = sphere2ZPosition - sphere1ZPosition;     distance = sqrt(distanceX * distanceX + distanceZ * distanceZ );      if (distance < (sphere1Radius + sphere2Radius))     { // Collision occurred } 

Does it matter if a brute force search for a password returns a collision and not the password?

Assume the following very basic hashing algorithm.

h(k) = k mod 17

Let’s say we create a password 12345 for a website that uses this very basic hashing algorithm. That would yield the hash of 3.

Say a brute force attacker comes by and starts guessing numbers starting at 1 they would only have to get to 3 before they got a hash collision and obviously 3 is not the original password.

Is the problem that the password hashing space (0-16) is much smaller than the space of the allowed password, or is there something else I’m overlooking?

Monogame Rectangle Collision Strange Behavior

So I’m making part of the original Legend of Zelda and I’m working on collisions. I want to get the this grey box to collide with the green box (and not be able to go into it). It works when I approach from the bottom, but when I approach from the left it doesn’t detect a collision until right after this point: enter image description here I used the hitbox rectangles as the destination rectangles for these sprites, so I know they have to be intersecting when they visually intersect, but they do not. I am using the Rectangle.Intersects method to detect the intersection, then Rectangle.Intersect to get the rectangle of the intersection. Here’s some of the code where rightTop is the green rectangle and collidable is grey:

public void CheckCollision(ICollidable collidable)     {         if (collidable.GetHitBox().X > maxX)         {             if (!rightOpen)             {                 collidable.SetPosition(maxX, collidable.GetHitBox().Y);                 collidable.BorderCollision();             }             else if (rightTop.Intersects(collidable.GetHitBox()))             {                 Rectangle intersection = Rectangle.Intersect(rightTop, collidable.GetHitBox());                if (intersection.Width > intersection.Height)                 {                     collidable.SetPosition(collidable.GetHitBox().X, rightTop.Bottom);                 }                 else if (intersection.Height > intersection.Width)                 {                     collidable.SetPosition(rightTop.Left-collidable.GetHitBox().Width, collidable.GetHitBox().Y);                 }                  else                 {                     collidable.SetPosition(rightTop.X, collidable.GetHitBox().Y);                 }             }          }      }