#Ground Check
1 messages · Page 1 of 1 (latest)
Yea it's a topdown game I can post a quick image for context if that helps express the nature of things visually
Code looks like it at least.
Mind posting a screenshot so I get an idea of how it works?
Weird, discord is acting a bit buggy, seems like messages aren't updating
er sorry the messages just updated now there's some kind of delay
here's a quick snapshot of the game, i can delete that if unecessary. temp assets/etc
It's been going on since at least yesterday.
I think i need to relog in or something, sec
Here's the ability manager for sprinting: https://gdl.space/iketacusad.cs
Here's the player movement script https://gdl.space/kuluceyecu.cs
i can also try and take a short vid showing the phasing
since that's probably easier than still images or vaguely describing it
initially, you can see that with default moveSpeed you don't move through the wall. but as soon as I add like 10 more speed, i can burrow through
(getting like a 10-20 second delay here lol)
Screenshot the Rigidbody component properties in the inspector
ok its posted, probably going to take about a minute to show up though. messages seem to be registering quicker*
I have gravity enabled because i noticed i'll start rotating or drifting when touching things, and gravity kinda forces that down. and I add custom gravity force on top of that to limit vertical jump/double jump
I could technically have the script handle gravity as well, but I figure just keeping the native settings might be easier to click off down the line for convenience
freezing position fixes the ball roll BUT you phase through walls like your kinematic, so i have to keep that unchecked
Ah i'm seeing the problem before seeing the solution (i.e. stopping random locked movement when rotating)- can't jump now because the velocity is canceling out upwards velocity per frame
I speculate your right about force being added while rotating which is making the character move without input, but I've gotta figure out how to work jumping into that or any other movement patterns, while removing all ball-like attributes
Does the wall have a Rigidbody?
I tracked the input and there was none so that's gotta be the last remaining cause. the only other thing would be trigger colliders, but afaik those don't produce collisions at all
Nope, it sounded expensive and i read you only want that on objects that 'interact' i.e. projectiles/players/enemies/etc
i'm keeping things 'performant' (from my limited understanding). Do i need to add a rigid?
that'd be a ton of rigid bodies in the scene on top of the projectiles and enemies
It's not required. It would just have to have been Static instead of Dynamic
My bad. I'm thinking Rigidbody2D logic
s'all good, it looks like rigid body kinematic isn't working either
It sounds like you're experiencing a multitude of issues in your current script
The approach I would recommend, is to break it all down in to parts, and fix each part individually
I wonder if an otherwise blank script with simple movement, would be able to penetrate that wall.
i think its speed related
kinematic is very different from a dynamic rigidbody
the standard speed doesn't let me go through which is good. but the more force applied the more you can phase through
right, from what i've read it's meant to be static and unmoveable, so it ignores certain things
but i think the answer is applying equal opposite force when touching a wall?
and or having a raycast that disables sprint when you touch it
that way you can never sprint through
Kinematic is not supposed to be immovable, but moved differently.
Ah gotcha
if isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore that's the part that i'm seeing
seeing where?
er in terms of how it interacts with the player
are you using it in the project right now?
like if the wall is kinematic, it cannot be moved by another rigid body- but on the flip it doesn't look like its stopping rigid bodies like the player's
i use kinematics for the pots
like kinematic when sitting in the level, then disable kinematics when thrown
then detects ground on collision to shatter, that works perfectly fine
i think the random movement might be solved, but i'll have to keep playing to see if it appears again.
But i think setting it to is grounded will fix the getting locked and moving in one direction without input issue seen here: https://gdl.space/aniqinepag.cpp
so 1 issue might be solved, the other one is phasing through things which I assumed raycasting might solve? since you're always forward facing when moving
like ya hit the wall at a short distance, then it disables your ability to sprint through a boolean as well as turns it off
you may be able to sprint while facing sideways then turning forwards, but i think the raycast will be too fast to try and cheeze that
First, make a simple movement scrip using only AddForce and see if that script alone can phase it through the wall
What sort of collider is on the wall?
alright
I got this script off a video i believe. I think the idea is to override the rigid body rotation because the rotation is disabled to keep it from rolling?
like rotating it from the outside, but you could be onto something
Overriding the Rigidbody rotation would conflict. Not every video out there is made by experts.
It sounds like you just want to freeze an axis of rotation?
X and Z because the character is just meant to rotate on one axis
Y is the primary axis for left/right rotation
So why override Rigidbody when it has Freeze Rotation X,Y,Z ?
it was rolling in addition to rotating
huh
The script rotates you forward (correct) but treats your character like a ball (makes sense) but that isn't what i want
maybe if my character was a ball things would be fine but it isn't
it also makes the character fall over or roll when another rigid/collider touches it
I'm not sure I comprehend
er "I want my rigid body to act like a character controller but still have features of a rigid body"
"because people say Character controller sucks and is limited, so I'm reprogramming the rigid body so i can have additional features"
"because down the line I might want to use some rigid body features that character controller doesn't have"
brb phone
Uh yep, i made a rudimentary movement script and can still pass through walls
https://gdl.space/rozoniyije.cs doesn't get any simpler than this. It's def gotta be some kind of collision/force issue
here's that basic script in action. Just changed the moveSpeed and same issue
i think raycasting to stop forward speed might be the best solution here
(that was a long phone call)
That's what I had in mind to suggest. I'm just not sure it's necessary. But it will absolutely work.
ye, i just gotta make sure the rays work, the green one is the forward wall detection
rays don't cancel eachother out right?
I don't believe so
hmm, i guess my issue now is that the second raycast is firing continually when its not detecting the layermask
https://gdl.space/siyakamawi.cs i called it hit2
How do you mean?
under the void update line is the wall detection ray, it looks like its firing constantly when i hit a wall. but i think whats happenign is an infinite ray is being shot out
because its hitting walls in the distance, but doesnt run when im pointing towards the void
ah maybe its transform.forward * height is the problem, shooting forward infinitely
i was using vector3.forward * height which worked for ground detection, but that kept it in world space and i need to localize it
i need something like vector3.forward.local or something like that
ah that's where i messed up, that was missing from my code
if(Physics.Raycast(rayCastOffset.position, transform.forward , out hit2, height2, _layerMaskWall))
instead of
if(Physics.Raycast(rayCastOffset.position, transform.forward * height2 , out hit2, _layerMaskWall))
That works?
checking
// origin direction hit info maxDistance layermask
if(Physics.Raycast(rayCastOffset.position, transform.forward , out hit2, height2, _layerMaskWall))
looks good
Yea i'm checking, it seems like its not running now but i may still be missing something
// Your code here
Ray ray2 = new Ray(rayCastOffset.position, transform.forward * height2);
Physics.Raycast(ray2, out hit2, height2, _layerMaskWall);
Debug.DrawRay(rayCastOffset.position, transform.forward * height2, Color.green);
if(Physics.Raycast(rayCastOffset.position, transform.forward , out hit2, height2, _layerMaskWall))
{
// disable dashing
playerAbilityManager.dashActive = false;
playerAbilityManager.dashIcon.SetActive(false);
Debug.Log("Detecting Wall, disabled dashing");
}
the ray is def following the transform locally which is good, im just trying to see if the debug log is even firing
ok i just tagged my walls as ground thats why
the rest i can debug, but do you have time for one last question?
I've got this beamer type enemy that shoots rays when it locks onto the character, but i want the wall layermask to break line of sight
its another raycast related thing. Do I use two raycasts, or would I use hit.collider.compareTag to differentiate within a single ray? I notice its causing stuttering when i try that
it'll interrupt, but the normal beam will stutter and stay in the previous position
I would just use a Raycast or SphereCast, and if it was null, the weapon can shoot.
Or search google to see how others solved it
Ok, yea I'll do that
I'm getting hungry now, so my brain is shutting down 😅
For any new questions, best ask the channel.
I'm barely equipped to help you with this, since it has been so long since I actually coded a game
Hey no problem, thanks for the help!
You're welcome. Good luck.
And try to make your next issue explained within a single post, with resources linked.
That will make it easier for people to pick up on your issue.