Announcement

Collapse
No announcement yet.

Make a Mouse controlled Object attach to Static Mesh In-Game

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Make a Mouse controlled Object attach to Static Mesh In-Game

    I'm using a fixed camera at the moment, so when I hit play, It spawns my object ( weapon cube) at my mouse location at a fixed distance. What I want to achieve is to make my spawned weapon cube attach and drag along a static mesh while hovering my mouse over it. I have two static meshes at different locations, so when I hover over the mesh, I want to weapon to snap on the surface of the static mesh. I realize that I need to use Line trace, but have no Idea how to make it work, and it is sort of difficult for me to understand the logic between finding the hit location and moving my weapon cube at that same hit location while it moves along the surface of the static mesh.

    Click image for larger version

Name:	inGameTest.png
Views:	1
Size:	147.5 KB
ID:	1226286

    Here is an example of my In-Game view. The cube in the air is controlled by my mouse, and I want to snap it to the meshes on the ground when my mouse hover over it.

    Click image for larger version

Name:	spawnWeapon.png
Views:	1
Size:	79.8 KB
ID:	1226287

    Here is my fixed character calling to spawn my weapon cube.

    Click image for larger version

Name:	WeaponBP.png
Views:	1
Size:	103.0 KB
ID:	1226288

    And here is my Weapon Blueprint.

    I want my weapon to have a fixed position, but If it hits the static mesh, I want the weapon cube to move to that position. Any help will be greatly appreciated!
Working...
X