When I say force, I don’t mean adding force to a rigid body with script, I mean like a star wars force-like script:
Where you can push enemies/objects back by hitting a key. Im working on a project that requires it. I was thinking I would do this with a raycast or something, but I am not very good with raycast. While I’m not the best with scripting, I am a lot more flexible with C#, so if you can help me with a script written in C#, that would be very much appreciated!
I appreciate any help! Thank you so much in advance!
mattyman is correct, but I believe I can help in your situation. If you aren’t the best at raycast, I suggest going with a sort of cone shape coming out of the main camera. Set the renderer to disabled (make sure this cone is attached to the camera as a child). Then place a script on the cone and use “Void OnTriggerEnter(Collider other)” to do your movements. The only problem is with this is how are you going to decide if you’re pushing or pulling? You can use either changing the transform directly or some tinkering with the rigidbody. Also make sure your “cone” is set to isTrigger. If you don’t know what I’m going for, whatever the cone is touching is whatever you can move. Only problem is clipping through walls and moving things like that…