Stopping MoveTo Touch with collision
vonshavingcream
Member Posts: 5
My first go at a game in GS.
I have an actor that I want to move to the touch location.
But I want it to stop if the collision object is in the way.
And then move again when a new touch is registered.
I've been running around in circles with this one all day. And I just feel like this is something that should be real easy in GS.
Any help or a point in the right direction would be great.
I can get the actor to stop on collision, but I can't get it to move again after that.
Thanks in advance,
C
I have an actor that I want to move to the touch location.
But I want it to stop if the collision object is in the way.
And then move again when a new touch is registered.
I've been running around in circles with this one all day. And I just feel like this is something that should be real easy in GS.
Any help or a point in the right direction would be great.
I can get the actor to stop on collision, but I can't get it to move again after that.
Thanks in advance,
C
Comments
If you upload an image to a file-sharing service, you can post the URL here as follows (remove the $ symbol):
<$img src="URL">
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
http://i.imgur.com/eVe38sY.jpg
Basically This is what I have worked out so far in terms of logic.
Timer = 0;
if Actor.HitWall(boolean) = false
then
Move To Touch Location
I also have this
Timer = 0;
if Actor Collides with Wall
then
set Actor.HitWall(boolean) = true;
I can get the Actor started moving and it works until it hits the wall, then it is just chaos.
I have
Actor.physics.bounciness = 0
Actor.physics.movable = 1
Wall.physics.bounciness = 0
Wall.physics.movable = 0
I can't think of anything else that might be worth mentioning.
thanks for any help.
C
So I would do what you have in your rules but in the otherwise section of the if hit block is false rule, add a move behavior and change it to 0 speed.
Maybe try that if that's what your talking about. Because I think the way you have it is that it is going to keep moving or trying to move even if it has hit a block unless you put in that otherwise statement.
okay .. setting move to 0 makes sense. I just assumed that when the actor stopped, it stopped. But it appears that is still trying to get to the MoveTo location even though the wall is in the way.
Is there a physics setting that would force the actors speed to goto 0 when it collides with the object?
i can code this answer with minimal lines of javascript. I don't understand why this is so difficult to make happen in GS. I really want to like this software, but I am getting frustrated by the minute.
a very simplified code for what I am trying to do
var cannonBall wall touch
if(touch)
while(move cannonBall to touch)
if(cannonBall hits wall)
stop cannonBall
I know that the code is very basic, but I don't understand how something this simple can be so complicated in GS. I really feel like I am missing something.
Here is what I did.
I put a log debug message in to check if attribule.Hitwall is true or false.
when I start the game the debug displays
Log(Actor: GameBoard_CanonBall): I am NOT touching a wall
over and over again.
when i touch the screen, the ball moves to the correct place.
when I touch an area that would force the ball to hit a wall i start getting this.
Log(Actor: GameBoard_CanonBall): I am NOT touching a wall
Log(Actor: GameBoard_CanonBall): I am touching a wall
Log(Actor: GameBoard_CanonBall): I am NOT touching a wall
over and over again.
How do I pull the ball off of the wall once it collides with it?
Have two actors, actor one is moving. Actor two is the wall.
Change bounciness to 0 on both actors.
Actor one:
Constrain self.rotation to zero
Collide with actor 2 ( the behaviour not the rule
Rule,
When touch is outside
Move to game.touch1 x and game.touch1 y
(make sure you tick run to completion)
A new rule that says
When collide or overlaps with actor 2
For 0.1 second ( run to completion)
Move at zero speed.
Then go on to actor two and make it unmoveable.
Hope that works for you
I can just email it to you if you want to pm your email address
Otherwise
I don't know what's wrong.
The rules are separate, they are not put in to one rule maybe you did that.
So for actor one you should have four different code groups.
When I test it and run into the wall. I cab either move up or down or back ect but no through it.
Thanks for helping me.
@vonshavingcream I know this is an old thread but if you figured it out it would help if you posted it the solution. I am actually having a similar issue where I need to use "Move To" with Run to completion on so that it completes the move each time. But if you move into a wall, it never is able to complete the move and it basically just tries forever to move to the spot that is behind the wall.
My Latest GS Game - Tiny Spirit
My First GS Game - Dashing Ralph